refactor: follow the google go style guide

Document every package and exported identifier, return the log level
from NewLogger instead of keeping it in a package variable, and stop
tests from mutating the argon2 parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:18:02 +01:00
1 parent 048e114fd9
commit d20225982a
21 files changed
+147 -36

No files matched your search

+8 -10
View File
@@ -7,15 +7,13 @@ import (
"git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo"
)
var logLevel = new(slog.LevelVar)
// NewLogger installs a JSON logger as the process default so output from the
// standard log package and dependencies ends up in the same format.
func NewLogger(component string) *slog.Logger {
l := slog.New(slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{Level: logLevel})).
// NewLogger returns a JSON logger tagged with component and the release
// version, and the level variable controlling it. The level can be changed
// once configuration is loaded; the logger is needed before that to report
// configuration errors.
func NewLogger(component string) (*slog.Logger, *slog.LevelVar) {
level := new(slog.LevelVar)
l := slog.New(slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{Level: level})).
With("component", component, "app_version", buildinfo.Version)
slog.SetDefault(l)
return l
return l, level
}
func SetLogLevel(l slog.Level) { logLevel.Set(l) }