Documentation ¶
Index ¶
- Constants
- Variables
- func BindFlags(flags *pflag.FlagSet)
- func BindGoFlags()
- func BrightF(msg string, args ...interface{}) string
- func Caller(skip ...int) string
- func CallerPC(skip ...int) uintptr
- func Debugf(format string, args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Infof(format string, args ...interface{})
- func IsDebugEnabled() bool
- func IsJsonLogs() bool
- func IsLevelEnabled(level int) bool
- func IsTraceEnabled() bool
- func Pretty(v any) string
- func Prettyf(msg string, obj interface{})
- func Secretf(format string, args ...interface{})
- func SetLogger(logger Logger)
- func Stacktrace() string
- func Tracef(format string, args ...interface{})
- func UseSlog()
- func Warnf(format string, args ...interface{})
- type LogLevel
- type Logger
- type SlogLogger
- func (s SlogLogger) Debugf(format string, args ...interface{})
- func (s SlogLogger) Errorf(format string, args ...interface{})
- func (s SlogLogger) Fatalf(format string, args ...interface{})
- func (s SlogLogger) GetLevel() LogLevel
- func (s SlogLogger) GetSlogLogger() *slog.Logger
- func (s SlogLogger) Infof(format string, args ...interface{})
- func (s SlogLogger) IsDebugEnabled() bool
- func (s SlogLogger) IsLevelEnabled(level LogLevel) bool
- func (s SlogLogger) IsTraceEnabled() bool
- func (s SlogLogger) Named(name string) Logger
- func (s SlogLogger) Prettyf(msg string, obj interface{})
- func (s SlogLogger) Secretf(format string, args ...interface{})
- func (s SlogLogger) SetLogLevel(level any)
- func (s SlogLogger) SetMinLogLevel(level any)
- func (s SlogLogger) Tracef(format string, args ...interface{})
- func (s SlogLogger) V(level any) Verbose
- func (s SlogLogger) Warnf(format string, args ...interface{})
- func (s SlogLogger) WithSkipReportLevel(i int) Logger
- func (s SlogLogger) WithV(level any) Logger
- func (s SlogLogger) WithValues(keysAndValues ...interface{}) Logger
- func (s SlogLogger) WithoutName() Logger
- type Verbose
Constants ¶
View Source
const ( Cyan = cyan + Normal Magenta = magenta + Normal DarkWhite = "\x1b[38;5;244m" Normal = "m" Reset = "\x1b[0m" )
Variables ¶
View Source
var SkipFrameContains = []string{
"gorm.io",
"golang.org/toolchain",
}
View Source
var SkipFrameSuffixes = []string{
"logger/slog.go",
"logger/default.go",
"logger/caller.go",
"gorm/logger.go",
"golang.org/toolchain",
}
View Source
var SlogFatal = slog.LevelError + 1
View Source
var SlogTraceLevel slog.Level = slog.LevelDebug - 1
View Source
var SlogTraceLevel1 slog.Level = SlogTraceLevel - 1
View Source
var SlogTraceLevel2 slog.Level = SlogTraceLevel - 2
View Source
var SlogTraceLevel3 slog.Level = SlogTraceLevel - 3
View Source
var SlogTraceLevel4 slog.Level = SlogTraceLevel - 4
Functions ¶
func BindGoFlags ¶ added in v1.21.2
func BindGoFlags()
func IsDebugEnabled ¶
func IsDebugEnabled() bool
func IsJsonLogs ¶ added in v1.20.1
func IsJsonLogs() bool
func IsLevelEnabled ¶ added in v1.20.1
func IsTraceEnabled ¶
func IsTraceEnabled() bool
func Prettyf ¶ added in v1.3.0
func Prettyf(msg string, obj interface{})
Prettyf is like Tracef, but pretty prints the entire struct
func Secretf ¶ added in v1.3.0
func Secretf(format string, args ...interface{})
Secretf is like Tracef, but attempts to strip any secrets from the text
func Stacktrace ¶ added in v1.26.0
func Stacktrace() string
Types ¶
type LogLevel ¶ added in v1.26.0
type LogLevel int
func FromSlogLevel ¶ added in v1.26.0
func ParseLevel ¶ added in v1.26.0
type Logger ¶
type Logger interface { Warnf(format string, args ...interface{}) Infof(format string, args ...interface{}) Errorf(format string, args ...interface{}) Debugf(format string, args ...interface{}) Tracef(format string, args ...interface{}) Fatalf(format string, args ...interface{}) WithValues(keysAndValues ...interface{}) Logger IsTraceEnabled() bool IsDebugEnabled() bool IsLevelEnabled(level LogLevel) bool GetLevel() LogLevel SetLogLevel(level any) SetMinLogLevel(level any) V(level any) Verbose WithV(level any) Logger Named(name string) Logger WithoutName() Logger WithSkipReportLevel(i int) Logger GetSlogLogger() *slog.Logger }
func StandardLogger ¶
func StandardLogger() Logger
func WithValues ¶ added in v1.4.2
func WithValues(keysAndValues ...interface{}) Logger
type SlogLogger ¶ added in v1.26.0
type SlogLogger struct { *slog.Logger Prefix string Level *slog.LevelVar Parent *SlogLogger // contains filtered or unexported fields }
func GetLogger ¶ added in v1.26.0
func GetLogger(names ...string) *SlogLogger
func GetSlogLogger ¶ added in v1.26.0
func GetSlogLogger() SlogLogger
func New ¶ added in v1.26.0
func New(prefix string) *SlogLogger
func (SlogLogger) Debugf ¶ added in v1.26.0
func (s SlogLogger) Debugf(format string, args ...interface{})
func (SlogLogger) Errorf ¶ added in v1.26.0
func (s SlogLogger) Errorf(format string, args ...interface{})
func (SlogLogger) Fatalf ¶ added in v1.26.0
func (s SlogLogger) Fatalf(format string, args ...interface{})
func (SlogLogger) GetLevel ¶ added in v1.26.0
func (s SlogLogger) GetLevel() LogLevel
func (SlogLogger) GetSlogLogger ¶ added in v1.26.0
func (s SlogLogger) GetSlogLogger() *slog.Logger
func (SlogLogger) Infof ¶ added in v1.26.0
func (s SlogLogger) Infof(format string, args ...interface{})
func (SlogLogger) IsDebugEnabled ¶ added in v1.26.0
func (s SlogLogger) IsDebugEnabled() bool
func (SlogLogger) IsLevelEnabled ¶ added in v1.26.0
func (s SlogLogger) IsLevelEnabled(level LogLevel) bool
func (SlogLogger) IsTraceEnabled ¶ added in v1.26.0
func (s SlogLogger) IsTraceEnabled() bool
func (SlogLogger) Named ¶ added in v1.26.0
func (s SlogLogger) Named(name string) Logger
func (SlogLogger) Prettyf ¶ added in v1.26.0
func (s SlogLogger) Prettyf(msg string, obj interface{})
func (SlogLogger) Secretf ¶ added in v1.26.0
func (s SlogLogger) Secretf(format string, args ...interface{})
func (SlogLogger) SetLogLevel ¶ added in v1.26.0
func (s SlogLogger) SetLogLevel(level any)
func (SlogLogger) SetMinLogLevel ¶ added in v1.26.0
func (s SlogLogger) SetMinLogLevel(level any)
func (SlogLogger) Tracef ¶ added in v1.26.0
func (s SlogLogger) Tracef(format string, args ...interface{})
func (SlogLogger) V ¶ added in v1.26.0
func (s SlogLogger) V(level any) Verbose
func (SlogLogger) Warnf ¶ added in v1.26.0
func (s SlogLogger) Warnf(format string, args ...interface{})
func (SlogLogger) WithSkipReportLevel ¶ added in v1.26.0
func (s SlogLogger) WithSkipReportLevel(i int) Logger
func (SlogLogger) WithV ¶ added in v1.26.0
func (s SlogLogger) WithV(level any) Logger
func (SlogLogger) WithValues ¶ added in v1.26.0
func (s SlogLogger) WithValues(keysAndValues ...interface{}) Logger
func (SlogLogger) WithoutName ¶ added in v1.26.0
func (s SlogLogger) WithoutName() Logger
Click to show internal directories.
Click to hide internal directories.