Documentation
¶
Index ¶
- Variables
- type Environment
- type HandleType
- type Handler
- type Log
- func (l *Log) Debug(msg string, keyValues ...any)
- func (l *Log) DebugContext(ctx context.Context, msg string, keyValues ...any)
- func (l *Log) Error(msg string, keyValues ...any)
- func (l *Log) ErrorContext(ctx context.Context, msg string, keyValues ...any)
- func (l *Log) Fatal(msg string, keyValues ...any)
- func (l *Log) FatalContext(ctx context.Context, msg string, keyValues ...any)
- func (l *Log) Info(msg string, keyValues ...any)
- func (l *Log) InfoContext(ctx context.Context, msg string, keyValues ...any)
- func (l *Log) Warn(msg string, keyValues ...any)
- func (l *Log) WarnContext(ctx context.Context, msg string, keyValues ...any)
- type Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultLogger = New(CONSOLE_HANDLER, Options{ Development: false, Debug: false, EnableCaller: false, SkipCaller: 3, })
DefaultLogger is the default Log with console handler.
Functions ¶
This section is empty.
Types ¶
type Environment ¶
type Environment uint8
const ( DEVELOPMENT Environment = iota PRODUCTION RELEASE )
func (Environment) String ¶
func (e Environment) String() string
type HandleType ¶
type HandleType uint8
const ( CONSOLE_HANDLER HandleType = iota TEXT_HANDLER JSON_HANDLER )
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewConsoleHandler ¶
func NewConsoleHandler(opts *slog.HandlerOptions) *Handler
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
func (*Log) DebugContext ¶
func (*Log) ErrorContext ¶
func (*Log) FatalContext ¶
func (*Log) InfoContext ¶
type Logger ¶
type Logger interface {
// Debug show debug log
Debug(msg string, args ...any)
// DebugContext show debug log with passing context
DebugContext(ctx context.Context, msg string, args ...any)
// Info show info log
Info(msg string, args ...any)
// InfoContext show info log with passing context
InfoContext(ctx context.Context, msg string, args ...any)
// Warn show warn log
Warn(msg string, args ...any)
// WarnContext show warn log with passing context
WarnContext(ctx context.Context, msg string, args ...any)
// Error show error log
Error(msg string, args ...any)
// ErrorContext show error log with passing context
ErrorContext(ctx context.Context, msg string, args ...any)
// Fatal show error log and exit application with os.Exit(1)
Fatal(msg string, args ...any)
// FatalContext show error log with passing context and exit application with os.Exit(1)
FatalContext(ctx context.Context, msg string, args ...any)
}
type Options ¶
type Options struct {
Development bool // Development add development details of machine
Debug bool // Debug show debug devel message
EnableCaller bool // EnableCaller show caller in line code
// SkipCaller skip caller level of CallerFrames
// https://github.com/golang/go/issues/59145#issuecomment-1481920720
SkipCaller int
CustomSlog *slog.Logger // CustomSlog set custom slog.Logger
CustomJsonHandler *slog.JSONHandler // CustomJsonHandler set custom slog.JsonHandler
}
Click to show internal directories.
Click to hide internal directories.