Documentation
¶
Index ¶
- Constants
- Variables
- func AnyValueToString(v slog.Value) string
- func AttrsToString(attrs ...slog.Attr) map[string]string
- func ContextExtractor(ctx context.Context, fns []func(ctx context.Context) []slog.Attr) []slog.Attr
- func Debug(args ...any)
- func DebugContext(ctx context.Context, args ...any)
- func Debugf(msg string, args ...any)
- func DebugfContext(ctx context.Context, msg string, args ...any)
- func DefaultConverter(addSource bool, replaceAttr func(groups []string, a slog.Attr) slog.Attr, ...) map[string]string
- func Error(args ...any)
- func ErrorContext(ctx context.Context, args ...any)
- func Errorf(msg string, args ...any)
- func ErrorfContext(ctx context.Context, msg string, args ...any)
- func ExtractFromContext(keys ...any) func(ctx context.Context) []slog.Attr
- func Info(args ...any)
- func InfoContext(ctx context.Context, args ...any)
- func Infof(msg string, args ...any)
- func InfofContext(ctx context.Context, msg string, args ...any)
- func LogWithAttrs(level Level, ctx context.Context, msg string, attrs ...slog.Attr)
- func NewDefaultHandler(w io.Writer, opts *slog.HandlerOptions, config *coreConfig) *defaultHandler
- func SetContextTraceId(ctx context.Context, traceId string) context.Context
- func SetLogger(l IFullLogger)
- func ValueToString(v slog.Value) string
- func Warn(args ...any)
- func WarnContext(ctx context.Context, args ...any)
- func Warnf(msg string, args ...any)
- func WarnfContext(ctx context.Context, msg string, args ...any)
- type ContextKey
- type Converter
- type Formatter
- type IContextFormatLogger
- type IContextLogger
- type ICustomLogger
- type IFormatLogger
- type IFullLogger
- type ILogger
- type Level
- type Option
- func WithAttrs(attrs ...slog.Attr) Option
- func WithFileSource() Option
- func WithFluentd(client *fluent.Fluent, tag string) Option
- func WithFormatter(formatter Formatter) Option
- func WithHandlerOptions(opt *slog.HandlerOptions) Option
- func WithLevel(level Level) Option
- func WithOutput(iow io.Writer) Option
- func WithRotateFile(f string) Option
- func WithTraceId() Option
- type SLogger
- func (l *SLogger) Debug(args ...any)
- func (l *SLogger) DebugContext(ctx context.Context, args ...any)
- func (l *SLogger) Debugf(msg string, args ...any)
- func (l *SLogger) DebugfContext(ctx context.Context, msg string, args ...any)
- func (l *SLogger) Error(args ...any)
- func (l *SLogger) ErrorContext(ctx context.Context, args ...any)
- func (l *SLogger) Errorf(msg string, args ...any)
- func (l *SLogger) ErrorfContext(ctx context.Context, msg string, args ...any)
- func (l *SLogger) Info(args ...any)
- func (l *SLogger) InfoContext(ctx context.Context, args ...any)
- func (l *SLogger) Infof(msg string, args ...any)
- func (l *SLogger) InfofContext(ctx context.Context, msg string, args ...any)
- func (l *SLogger) Log(level Level, msg string)
- func (l *SLogger) LogCtxf(level Level, ctx context.Context, format string, kvs ...interface{})
- func (l *SLogger) LogWithAttrs(level Level, ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *SLogger) Logf(level Level, format string, kvs ...interface{})
- func (l *SLogger) SetLevel(level Level)
- func (l *SLogger) SetOutput(writer io.Writer)
- func (l *SLogger) Warn(args ...any)
- func (l *SLogger) WarnContext(ctx context.Context, args ...any)
- func (l *SLogger) Warnf(msg string, args ...any)
- func (l *SLogger) WarnfContext(ctx context.Context, msg string, args ...any)
Constants ¶
Variables ¶
var SourceKey = "source"
Functions ¶
func AnyValueToString ¶
func ContextExtractor ¶
func DebugContext ¶
DebugContext calls the default logger's DebugContext method.
func DebugfContext ¶
DebugfContext calls the default logger's DebugfContext method.
func DefaultConverter ¶
func ErrorContext ¶
ErrorContext calls the default logger's ErrorContext method.
func ErrorfContext ¶
ErrorfContext calls the default logger's ErrorfContext method.
func ExtractFromContext ¶
func InfoContext ¶
InfoContext calls the default logger's InfoContext method.
func InfofContext ¶
InfofContext calls the default logger's InfofContext method.
func LogWithAttrs ¶
func NewDefaultHandler ¶
func NewDefaultHandler(w io.Writer, opts *slog.HandlerOptions, config *coreConfig) *defaultHandler
func SetContextTraceId ¶
func SetLogger ¶
func SetLogger(l IFullLogger)
SetLogger sets the default logger. Note that this method is not concurrent-safe and must not be called after the use of DefaultLogger and global functions in this package.
func ValueToString ¶
func WarnContext ¶
WarnContext calls the default logger's WarnContext method.
Types ¶
type ContextKey ¶
type ContextKey string
type IContextFormatLogger ¶
type IContextLogger ¶
type ICustomLogger ¶
type IFormatLogger ¶
type IFullLogger ¶
type IFullLogger interface { ILogger IFormatLogger IContextLogger IContextFormatLogger ICustomLogger }
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option slog option
func WithFileSource ¶
func WithFileSource() Option
func WithFluentd ¶
WithFluentd fluentd config
func WithFormatter ¶
WithFormatter formatter default json. Enum: json or text
func WithHandlerOptions ¶
func WithHandlerOptions(opt *slog.HandlerOptions) Option
WithHandlerOptions slog handler-options
func WithTraceId ¶
func WithTraceId() Option
type SLogger ¶
type SLogger struct {
// contains filtered or unexported fields
}