-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.go
42 lines (34 loc) · 1.31 KB
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package log
import (
"context"
"github.com/go-coldbrew/log/loggers"
)
// SetLevel sets the log level to filter logs
func SetLevel(level loggers.Level) {
GetLogger().SetLevel(level)
}
// GetLevel returns the current log level
// This is useful for checking if a log level is enabled
func GetLevel() loggers.Level {
return GetLogger().GetLevel()
}
// Debug writes out a debug log to global logger
// This is a convenience function for GetLogger().Log(loggers.DebugLevel, 1, args...)
func Debug(ctx context.Context, args ...interface{}) {
GetLogger().Log(ctx, loggers.DebugLevel, 1, args...)
}
// Info writes out an info log to global logger
// This is a convenience function for GetLogger().Log(loggers.InfoLevel, 1, args...)
func Info(ctx context.Context, args ...interface{}) {
GetLogger().Log(ctx, loggers.InfoLevel, 1, args...)
}
// Warn writes out a warning log to global logger
// This is a convenience function for GetLogger().Log(loggers.WarnLevel, 1, args...)
func Warn(ctx context.Context, args ...interface{}) {
GetLogger().Log(ctx, loggers.WarnLevel, 1, args...)
}
// Error writes out an error log to global logger
// This is a convenience function for GetLogger().Log(loggers.ErrorLevel, 1, args...)
func Error(ctx context.Context, args ...interface{}) {
GetLogger().Log(ctx, loggers.ErrorLevel, 1, args...)
}