refactor(logging): move logging setup to internal/logging
Moves logging configuration and setup to a dedicated package. Updates Config struct to use nested LoggingConfig. Updates main.go to use the new logging package.
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/placeholder/golang-template/internal/config"
|
||||
"github.com/placeholder/golang-template/internal/logging"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -27,11 +28,9 @@ func main() {
|
||||
}
|
||||
|
||||
// Setup Logger
|
||||
opts := &slog.HandlerOptions{
|
||||
Level: config.ParseLogLevel(cfg.LogLevel),
|
||||
}
|
||||
logger := slog.New(slog.NewJSONHandler(os.Stdout, opts))
|
||||
slog.SetDefault(logger)
|
||||
logging.Configure(logging.Config{
|
||||
Level: cfg.Logging.Level,
|
||||
})
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
Reference in New Issue
Block a user