Compare commits

...

2 commits

Author SHA1 Message Date
FabricSoul
a638a63731 add logger 2025-07-15 22:24:08 -04:00
FabricSoul
38cea96107 add .gitignore 2025-07-15 22:23:45 -04:00
2 changed files with 30 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.env

29
pkg/logger/logger.go Normal file
View file

@ -0,0 +1,29 @@
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()
}
}