From 0a47f12905fae8d203d4af06fd56dbcb51c6038d Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Fri, 17 Dec 2021 00:25:29 +0800 Subject: [PATCH] update --- auth/service.go | 1 + history/service.go | 6 ++++-- util/logging.go | 3 +++ util/logging_test.go | 22 ++++++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/auth/service.go b/auth/service.go index 85e3749..bde9f4c 100644 --- a/auth/service.go +++ b/auth/service.go @@ -29,6 +29,7 @@ func New(s *server.Service) *Service { func (srv Service) GetName() string { return "auth.Service" } func (srv Service) GetDependencies() []string { return []string{"server.Service", "auth.Auth"} } +func (srv Service) IsService() bool { return true } func (srv Service) Init() error { srv.Logger = log.With().Str("mod", "auth").Str("service", "auth.Service").Logger() diff --git a/history/service.go b/history/service.go index e561d71..e05f3d6 100644 --- a/history/service.go +++ b/history/service.go @@ -11,8 +11,10 @@ type Service struct { system.BaseService } -func (srv Service) GetName() string { return "history.Service" } -func (srv Service) IsService() bool { return true } +func (srv Service) GetName() string { return "history.Service" } +func (srv Service) IsService() bool { return true } +func (srv Service) GetDependencies() []string { return []string{"server.Service"} } + func (srv Service) Init() error { PROD = viper.GetBool("prod") l := log.With().Str("mod", "history"). diff --git a/util/logging.go b/util/logging.go index 2111582..6d170f9 100644 --- a/util/logging.go +++ b/util/logging.go @@ -36,6 +36,9 @@ func CallerMod(depth int) (mod, file string) { break } } + if f[i] == '@' { + ptr = i + } } return } diff --git a/util/logging_test.go b/util/logging_test.go index 4e456d6..030f899 100644 --- a/util/logging_test.go +++ b/util/logging_test.go @@ -20,3 +20,25 @@ func TestCallerMod(t *testing.T) { func TestCaller(t *testing.T) { fmt.Println(Caller(1)) } + +func TestStringer(t *testing.T) { + f := "test/cbox@v0.0.0-20211216161916-9173e9f37ab9/service.go" + ptr := 0 + file := "" + mod := "" + for i := len(f) - 1; i > 0; i-- { + if f[i] == '/' { + if ptr == 0 { + file = f[i+1:] + ptr = i + } else { + mod = f[i+1 : ptr] + break + } + } + if f[i] == '@' { + ptr = i + } + } + fmt.Println(mod, file) +}