Replace zerolog with log/slog from stdlib

- Rewrite logger package to use slog with LevelVar for dynamic levels
- Update all packages to use *slog.Logger instead of *zerolog.Logger
- Use TextHandler for TTY (dev), JSONHandler for production
- Add make check target (runs lint + test)
- Add make test target
This commit is contained in:
2025-12-27 12:02:05 +07:00
parent a8412af0c2
commit fb347b96df
14 changed files with 76 additions and 129 deletions

View File

@@ -2,10 +2,10 @@ package database
import (
"context"
"log/slog"
"git.eeqj.de/sneak/gohttpserver/internal/config"
"git.eeqj.de/sneak/gohttpserver/internal/logger"
"github.com/rs/zerolog"
"go.uber.org/fx"
// spooky action at a distance!
@@ -26,7 +26,7 @@ type DatabaseParams struct {
type Database struct {
URL string
log *zerolog.Logger
log *slog.Logger
params *DatabaseParams
}
@@ -35,11 +35,11 @@ func New(lc fx.Lifecycle, params DatabaseParams) (*Database, error) {
s.params = &params
s.log = params.Logger.Get()
s.log.Info().Msg("Database instantiated")
s.log.Info("Database instantiated")
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
s.log.Info().Msg("Database OnStart Hook")
s.log.Info("Database OnStart Hook")
// FIXME connect to db
return nil
},