diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.go | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -104,8 +104,26 @@ func (uuid UUID) ToString() string { +type LogLevel int8 + +const ( + LevelNone LogLevel = 0 + LevelError LogLevel = 1 + LevelWarning LogLevel = 2 + LevelInfo LogLevel = 3 + LevelDebug LogLevel = 4 +) + +var Level LogLevel = LevelInfo + +var EmitMetric bool = true + func Debug(message string, type_ string, args ...any) { + if (Level < LevelDebug) { + return + } + slog.Debug( message, append( @@ -120,6 +138,10 @@ func Debug(message string, type_ string, args ...any) { } func Info(message string, type_ string, args ...any) { + if (Level < LevelInfo) { + return + } + slog.Info( message, append( @@ -134,6 +156,10 @@ func Info(message string, type_ string, args ...any) { } func Warning(message string, type_ string, args ...any) { + if (Level < LevelWarning) { + return + } + slog.Warn( message, append( @@ -148,6 +174,10 @@ func Warning(message string, type_ string, args ...any) { } func Error(message string, type_ string, args ...any) { + if (Level < LevelError) { + return + } + slog.Error( message, append( @@ -162,6 +192,10 @@ func Error(message string, type_ string, args ...any) { } func Metric(type_ string, label string, args ...any) { + if (!EmitMetric) { + return + } + slog.Info( "_", append( |