From 38cea96107242e06490ad040cbda18a3b88c744a Mon Sep 17 00:00:00 2001 From: FabricSoul Date: Tue, 15 Jul 2025 22:23:45 -0400 Subject: [PATCH 1/2] add .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env From a638a63731dd1996ed357f767bfa3404815fc66f Mon Sep 17 00:00:00 2001 From: FabricSoul Date: Tue, 15 Jul 2025 22:24:08 -0400 Subject: [PATCH 2/2] add logger --- pkg/logger/logger.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pkg/logger/logger.go diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go new file mode 100644 index 0000000..ae719ca --- /dev/null +++ b/pkg/logger/logger.go @@ -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() + } +}