Compare commits
No commits in common. "a638a63731dd1996ed357f767bfa3404815fc66f" and "fd2fbb37140b0b4ef661c23b2e0781219e51e7ac" have entirely different histories.
a638a63731
...
fd2fbb3714
2 changed files with 0 additions and 30 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
.env
|
|
@ -1,29 +0,0 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Sugar is a global instance of the zap sugared logger.
|
||||
var Sugar *zap.SugaredLogger
|
||||
|
||||
// Init initializes the global logger and returns a cleanup function.
|
||||
// The cleanup function should be deferred in the main function.
|
||||
func Init() func() {
|
||||
// NewProduction builds a sensible production logger that writes InfoLevel and
|
||||
// above logs to standard error.
|
||||
coreLogger, err := zap.NewDevelopment()
|
||||
if err != nil {
|
||||
log.Fatalf("can't initialize zap logger: %v", err)
|
||||
}
|
||||
|
||||
// Assign the sugared logger to our global variable.
|
||||
Sugar = coreLogger.Sugar()
|
||||
|
||||
// Return the Sync function to be deferred by the caller.
|
||||
return func() {
|
||||
_ = coreLogger.Sync()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue