@@ -6,23 +6,17 @@ import (
66 "path/filepath"
77 "runtime"
88 "strings"
9- "sync"
109
1110 "github.com/rs/zerolog"
1211)
1312
14- var (
15- log zerolog.Logger
16- mu sync.RWMutex
17- )
13+ var Log zerolog.Logger
1814
19- const (
20- timeFormat = "2006-01-02 15:04:05.000"
21- )
15+ const timeFormat = "2006-01-02 15:04:05.000"
2216
2317// Config defines parameters for the logger
2418type Config struct {
25- Level string `mapstructure:"level"`
19+ Level string `mapstructure:"level"`
2620}
2721
2822// Init initializes the package logger.
@@ -72,50 +66,24 @@ func Init(level string, fixByFile, fixByFunc []string) {
7266 return fmt .Sprintf ("[%d][%s][%s] => %s" , line , fileName , funcName , i )
7367 }
7468
75- mu .Lock ()
76- log = zerolog .New (output ).Level (l ).With ().Timestamp ().Logger ()
77- mu .Unlock ()
69+ Log = zerolog .New (output ).Level (l ).With ().Timestamp ().Logger ()
7870}
7971
8072// Infof logs a formatted info level log to the console
81- func Infof (format string , v ... interface {}) {
82- mu .RLock ()
83- defer mu .RUnlock ()
84- log .Info ().Msgf (format , v ... )
85- }
73+ func Infof (format string , v ... interface {}) { Log .Info ().Msgf (format , v ... ) }
8674
8775// Tracef logs a formatted debug level log to the console
88- func Tracef (format string , v ... interface {}) {
89- mu .RLock ()
90- defer mu .RUnlock ()
91- log .Trace ().Msgf (format , v ... )
92- }
76+ func Tracef (format string , v ... interface {}) { Log .Trace ().Msgf (format , v ... ) }
9377
9478// Debugf logs a formatted debug level log to the console
95- func Debugf (format string , v ... interface {}) {
96- mu .RLock ()
97- defer mu .RUnlock ()
98- log .Debug ().Msgf (format , v ... )
99- }
79+ func Debugf (format string , v ... interface {}) { Log .Debug ().Msgf (format , v ... ) }
10080
10181// Warnf logs a formatted warn level log to the console
102- func Warnf (format string , v ... interface {}) {
103- mu .RLock ()
104- defer mu .RUnlock ()
105- log .Warn ().Msgf (format , v ... )
106- }
82+ func Warnf (format string , v ... interface {}) { Log .Warn ().Msgf (format , v ... ) }
10783
10884// Errorf logs a formatted error level log to the console
109- func Errorf (format string , v ... interface {}) {
110- mu .RLock ()
111- defer mu .RUnlock ()
112- log .Error ().Msgf (format , v ... )
113- }
85+ func Errorf (format string , v ... interface {}) { Log .Error ().Msgf (format , v ... ) }
11486
11587// Panicf logs a formatted panic level log to the console.
11688// The panic() function is called, which stops the ordinary flow of a goroutine.
117- func Panicf (format string , v ... interface {}) {
118- mu .RLock ()
119- defer mu .RUnlock ()
120- log .Panic ().Msgf (format , v ... )
121- }
89+ func Panicf (format string , v ... interface {}) { Log .Panic ().Msgf (format , v ... ) }
0 commit comments