Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Level is the level of the logger.
Level Level
}
Config is the configuration of the logger.
type Entry ¶
type Entry struct {
Timestamp int64 `json:"timestamp"`
Level Level `json:"-"`
LevelStr string `json:"level"`
Name string `json:"name"`
Version string `json:"version"`
Trace trace.Trace `json:"trace"`
Error error `json:"error,omitempty"`
Info map[string]any `json:"info"`
Msg string `json:"msg"`
}
Entry is the json representation of a log entry.
type Level ¶
type Level int
Level is the level of the logger.
const ( // LEVEL_TRACE is the trace level. LEVEL_TRACE Level = (iota + 1) * 10 // LEVEL_DEBUG is the debug level. LEVEL_DEBUG // LEVEL_INFO is the info level. LEVEL_INFO // LEVEL_WARN is the warn level. LEVEL_WARN // LEVEL_ERROR is the error level. LEVEL_ERROR // LEVEL_FATAL is the fatal level. LEVEL_FATAL )
func NewLevelFromString ¶
NewLevelFromString returns a level from a string. If the string is not a valid level, an error of type *errors.Error is returned.
type Logger ¶
type Logger interface {
// Trace logs a message with the LEVEL_TRACE level.
Trace(ctx context.Context, msg string)
// TraceWithData logs a message with the LEVEL_TRACE level
// and the given data.
TraceWithData(ctx context.Context, msg string, data map[string]any)
// Debug logs a message with the LEVEL_DEBUG level.
Debug(ctx context.Context, msg string)
// DebugWithData logs a message with the LEVEL_DEBUG level
// and the given data.
DebugWithData(ctx context.Context, msg string, data map[string]any)
// Info logs a message with the LEVEL_INFO level.
Info(ctx context.Context, msg string)
// InfoWithData logs a message with the LEVEL_INFO level
// and the given data.
InfoWithData(ctx context.Context, msg string, data map[string]any)
// Warn logs a message with the LEVEL_WARN level.
Warn(ctx context.Context, msg string, err error)
// WarnWithData logs a message with the LEVEL_WARN level
// and the given data.
WarnWithData(ctx context.Context, msg string, err error, data map[string]any)
// Error logs a message with the LEVEL_ERROR level.
Error(ctx context.Context, msg string, err error)
// ErrorWithData logs a message with the LEVEL_ERROR level
// and the given data.
ErrorWithData(ctx context.Context, msg string, err error, data map[string]any)
// Fatal logs a message with the LEVEL_FATAL level and it's followed by a
// call to os.Exit(1).
Fatal(ctx context.Context, msg string, err error)
// FatalWithData logs a message with the LEVEL_FATAL level
// and the given data and it's followed by a call to os.Exit(1).
FatalWithData(ctx context.Context, msg string, err error, data map[string]any)
}
Click to show internal directories.
Click to hide internal directories.