Documentation
¶
Overview ¶
Package types contains the types for the log package.
Index ¶
Constants ¶
View Source
const ( TraceStr = "trace" DebugStr = "debug" InfoStr = "info" WarnStr = "warn" ErrorStr = "error" CriticalStr = "critical" OffStr = "off" )
Log level string representations
Variables ¶
This section is empty.
Functions ¶
func ToSlogLevel ¶
ToSlogLevel converts a LogLevel to a slog.Level
Types ¶
type LogLevel ¶
LogLevel is the type of log levels
const ( TraceLvl LogLevel = LogLevel(slog.LevelDebug - 4) DebugLvl LogLevel = LogLevel(slog.LevelDebug) InfoLvl LogLevel = LogLevel(slog.LevelInfo) WarnLvl LogLevel = LogLevel(slog.LevelWarn) ErrorLvl LogLevel = LogLevel(slog.LevelError) CriticalLvl LogLevel = LogLevel(slog.LevelError + 4) Off LogLevel = LogLevel(slog.LevelError + 8) )
Log levels
func FromSlogLevel ¶
FromSlogLevel converts a slog.Level to a LogLevel
type LoggerInterface ¶
type LoggerInterface interface {
// Trace formats message using the default formats for its operands
// and writes to log with level = Trace
Trace(v ...interface{})
// Debug formats message using the default formats for its operands
// and writes to log with level = Debug
Debug(v ...interface{})
// Info formats message using the default formats for its operands
// and writes to log with level = Info
Info(v ...interface{})
// Warn formats message using the default formats for its operands
// and writes to log with level = Warn
Warn(v ...interface{}) error
// Error formats message using the default formats for its operands
// and writes to log with level = Error
Error(v ...interface{}) error
// Critical formats message using the default formats for its operands
// and writes to log with level = Critical
Critical(v ...interface{}) error
// Close flushes all the messages in the logger and closes it. It cannot be used after this operation.
Close()
// Flush flushes all the messages in the logger.
Flush()
// SetAdditionalStackDepth sets the additional number of frames to skip by runtime.Caller
SetAdditionalStackDepth(depth int) error
// Sets logger context that can be used in formatter funcs and custom receivers
SetContext(context interface{})
// Tracef formats message according to format specifier
// and writes to log with level = Trace.
Tracef(format string, params ...interface{})
// Debugf formats message according to format specifier
// and writes to log with level = Debug.
Debugf(format string, params ...interface{})
// Infof formats message according to format specifier
// and writes to log with level = Info.
Infof(format string, params ...interface{})
// Warnf formats message according to format specifier
// and writes to log with level = Warn.
Warnf(format string, params ...interface{}) error
// Errorf formats message according to format specifier
// and writes to log with level = Error.
Errorf(format string, params ...interface{}) error
// Criticalf formats message according to format specifier
// and writes to log with level = Critical.
Criticalf(format string, params ...interface{}) error
}
LoggerInterface provides basic logging methods that can be used from outside the log package.
Click to show internal directories.
Click to hide internal directories.