Documentation ¶
Index ¶
- Variables
- func CtxAppendLoggerAttrs(ctx context.Context, attrs ...slog.Attr) context.Context
- func CtxWithLoggerAttrs(ctx context.Context, attrs ...slog.Attr) context.Context
- func GetLoggerAttrsFromCtx(ctx ValueContext) []slog.Attr
- func NewSlogLogger(logger Logger) *slog.Logger
- func SetDefaultLoggerFactory(f *LoggerFactory)
- type Logger
- func GetLogger() Logger
- func GetLoggerForPath(pth string) Logger
- func GetLoggerForType(forType any) Logger
- func GetLoggerFromCtx(ctx ValueContext) Logger
- func GetLoggerFromCtxForPath(ctx ValueContext, pth string) Logger
- func GetLoggerFromCtxForType(ctx ValueContext, forType any) Logger
- func GetRootLogger() Logger
- func NewLogger(conf config.RootConfig, name string) Logger
- func NewLoggerWithWriter(conf config.RootConfig, name string, writer io.Writer) Logger
- func (l Logger) Debug(msg string, args ...any)
- func (l Logger) Debugf(format string, args ...any)
- func (l Logger) Enabled(level config.LogLevel) bool
- func (l Logger) Error(msg string, args ...any)
- func (l Logger) ErrorE(err error)
- func (l Logger) Errorf(format string, args ...any)
- func (l Logger) Info(msg string, args ...any)
- func (l Logger) Infof(format string, args ...any)
- func (l Logger) Level() config.LogLevel
- func (l Logger) Log(level config.LogLevel, msg string, args ...any)
- func (l Logger) LogAttrs(level config.LogLevel, msg string, attrs ...slog.Attr)
- func (l Logger) SetLevel(level config.LogLevel)
- func (l Logger) Trace(msg string, args ...any)
- func (l Logger) Tracef(format string, args ...any)
- func (l Logger) Warn(msg string, args ...any)
- func (l Logger) Warnf(format string, args ...any)
- func (l Logger) With(args ...any) Logger
- func (l Logger) WithAttrs(attrs ...slog.Attr) Logger
- func (l Logger) WithContext(ctx context.Context) Logger
- func (l Logger) Writer() io.Writer
- type LoggerFactory
- func (lf *LoggerFactory) GetLogger() Logger
- func (lf *LoggerFactory) GetLoggerForPath(pth string) Logger
- func (lf *LoggerFactory) GetLoggerForType(forType any) Logger
- func (lf *LoggerFactory) GetLoggerFromCtx(ctx ValueContext) Logger
- func (lf *LoggerFactory) GetLoggerFromCtxForPath(ctx ValueContext, pth string) Logger
- func (lf *LoggerFactory) GetLoggerFromCtxForType(ctx ValueContext, forType any) Logger
- func (lf *LoggerFactory) GetRootLogger() Logger
- func (lf *LoggerFactory) SetCtx(ctx context.Context) context.Context
- type ValueContext
Constants ¶
This section is empty.
Variables ¶
var Module = fx.Provide(NewLoggerFactory)
var (
SkipAttr = slog.Attr{}
)
Functions ¶
func CtxAppendLoggerAttrs ¶
CtxAppendLoggerAttrs adds the given attributes to the context, it will append to any existing attributes.
func CtxWithLoggerAttrs ¶
CtxWithLoggerAttrs sets the given attributes to the context, it will overwrite any existing attributes.
func GetLoggerAttrsFromCtx ¶
func GetLoggerAttrsFromCtx(ctx ValueContext) []slog.Attr
GetLoggerAttrsFromCtx returns the attributes from the context, or nil if there are none.
func NewSlogLogger ¶
func SetDefaultLoggerFactory ¶
func SetDefaultLoggerFactory(f *LoggerFactory)
SetDefaultLoggerFactory sets the default logger factory to use for the package-level functions.
Types ¶
type Logger ¶
type Logger struct { SkipCallers int // contains filtered or unexported fields }
Logger structure
func GetLogger ¶
func GetLogger() Logger
GetLogger returns a logger for the caller using the default logger factory.
func GetLoggerForPath ¶
GetLoggerForPath returns a logger for the given path and adds the context properties (if any) using the default logger factory.
func GetLoggerForType ¶
GetLoggerForType returns a logger for the given type and adds the context properties (if any) using the default logger factory.
func GetLoggerFromCtx ¶
func GetLoggerFromCtx(ctx ValueContext) Logger
GetLoggerFromCtx returns a logger for the caller and adds the context properties (if any). Default logger Factory will be used if there is none in the context.
func GetLoggerFromCtxForPath ¶
func GetLoggerFromCtxForPath(ctx ValueContext, pth string) Logger
GetLoggerFromCtxForPath returns a logger for the given path and adds the context properties (if any) using the default logger factory.
func GetLoggerFromCtxForType ¶
func GetLoggerFromCtxForType(ctx ValueContext, forType any) Logger
GetLoggerFromCtxForType returns a logger for the given type and adds the context properties (if any) using
func GetRootLogger ¶
func GetRootLogger() Logger
GetRootLogger returns the root logger using the default logger factory.
func NewLogger ¶
func NewLogger(conf config.RootConfig, name string) Logger
NewLogger creates a new logger with the given core configuration.
func NewLoggerWithWriter ¶
NewLoggerWithWriter creates a new logger with the given core configuration and writer.
func (Logger) WithContext ¶
WithContext returns a new logger with the given context.
type LoggerFactory ¶
type LoggerFactory struct {
// contains filtered or unexported fields
}
func GetDefaultLoggerFactory ¶
func GetDefaultLoggerFactory() *LoggerFactory
GetDefaultLoggerFactory returns the default logger factory used by the package-level functions.
func NewLoggerFactory ¶
func NewLoggerFactory(coreConfig config.RootConfig) *LoggerFactory
NewLoggerFactory creates a new logger factory with the given core configuration.
func NewLoggerFactoryWithWriter ¶
func NewLoggerFactoryWithWriter(coreConfig config.RootConfig, writer io.Writer) *LoggerFactory
NewLoggerFactoryWithWriter creates a new logger factory with the given core configuration and writer.
func (*LoggerFactory) GetLogger ¶
func (lf *LoggerFactory) GetLogger() Logger
GetLogger returns a logger for the caller
func (*LoggerFactory) GetLoggerForPath ¶
func (lf *LoggerFactory) GetLoggerForPath(pth string) Logger
GetLoggerForPath returns a logger for the given path and adds the context properties (if any).
func (*LoggerFactory) GetLoggerForType ¶
func (lf *LoggerFactory) GetLoggerForType(forType any) Logger
GetLoggerForType returns a logger for the given type and adds the context properties (if any).
func (*LoggerFactory) GetLoggerFromCtx ¶
func (lf *LoggerFactory) GetLoggerFromCtx(ctx ValueContext) Logger
GetLoggerFromCtx returns a logger for the caller and adds the context properties (if any)
func (*LoggerFactory) GetLoggerFromCtxForPath ¶
func (lf *LoggerFactory) GetLoggerFromCtxForPath(ctx ValueContext, pth string) Logger
GetLoggerFromCtxForPath returns a logger for the given type and adds the context properties (if any)
func (*LoggerFactory) GetLoggerFromCtxForType ¶
func (lf *LoggerFactory) GetLoggerFromCtxForType(ctx ValueContext, forType any) Logger
GetLoggerFromCtxForType returns a logger for the given type and adds the context properties (if any)
func (*LoggerFactory) GetRootLogger ¶
func (lf *LoggerFactory) GetRootLogger() Logger
GetRootLogger returns the root logger. This is a shortcut for GetLoggerForPath("/").