Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(msg string, args ...any)
- func Debugf(format string, args ...any)
- func Default() *slog.Logger
- func Error(msg string, args ...any)
- func Errorf(format string, args ...any)
- func Fatal(msg any, args ...any)
- func Fatalf(format string, args ...any)
- func Highlight(text string) string
- func Important(msg string, args ...any)
- func Importantf(format string, args ...any)
- func Info(msg string, args ...any)
- func Infof(format string, args ...any)
- func LogLevelString(l Level) string
- func New(opts ...Option) (*slog.Logger, error)
- func Reset()
- func SetCallerFormatter(f CallerFormatter, loggers ...*slog.Logger)
- func SetCallerOffset(offset int, loggers ...*slog.Logger)
- func SetFormatter(f Formatter, loggers ...*slog.Logger)
- func SetLevel(level Level, loggers ...*slog.Logger)
- func SetOutput(w io.Writer, loggers ...*slog.Logger)
- func SetPrefix(prefix string, loggers ...*slog.Logger)
- func SetReportCaller(report bool, loggers ...*slog.Logger)
- func SetReportTimestamp(report bool, loggers ...*slog.Logger)
- func SetStyles(s *Styles, loggers ...*slog.Logger)
- func SetTimeFormat(format string, loggers ...*slog.Logger)
- func SetTimeFunction(f TimeFunction, loggers ...*slog.Logger)
- func UnderBold(text string) string
- func Warn(msg string, args ...any)
- func Warnf(format string, args ...any)
- func WithPrefix(l *slog.Logger, prefix string) *slog.Logger
- type CallerFormatter
- type Formatter
- type Level
- type Logger
- type Option
- func AsDefault() Option
- func EnableRotation(maxSize string, maxFiles int) Option
- func UseLevel(l Level) Option
- func UseOutput(w io.Writer) Option
- func UseOutputFunc(f func() (io.Writer, error)) Option
- func UseOutputPath(path string) Option
- func UseReportCaller(report bool) Option
- func UseReportTimestamp(report bool) Option
- func UseStyles(s *Styles) Option
- func UseTimeFormat(format string) Option
- type Options
- type Styles
- type TimeFunction
Constants ¶
const ( DebugLevel = charmlog.DebugLevel InfoLevel = charmlog.InfoLevel WarnLevel = charmlog.WarnLevel ErrorLevel = charmlog.ErrorLevel FatalLevel = charmlog.FatalLevel ImportantLevel = WarnLevel + 1 )
const ( TextFormatter = charmlog.TextFormatter JSONFormatter = charmlog.JSONFormatter LogfmtFormatter = charmlog.LogfmtFormatter )
Formatters
Variables ¶
var ( ShortCallerFormatter = charmlog.ShortCallerFormatter LongCallerFormatter = charmlog.LongCallerFormatter )
Caller Formatters
Functions ¶
func Importantf ¶
func LogLevelString ¶
LogLevel returns the string representation of the level
func SetCallerFormatter ¶
func SetCallerFormatter(f CallerFormatter, loggers ...*slog.Logger)
SetCallerFormatter sets the caller formatter.
func SetCallerOffset ¶
SetCallerOffset sets the caller offset.
func SetFormatter ¶
SetFormatter sets the formatter.
func SetReportCaller ¶
SetReportCaller sets whether to report caller location.
func SetReportTimestamp ¶
SetReportTimestamp sets whether to report timestamp.
func SetTimeFormat ¶
SetTimeFormat sets the time format.
func SetTimeFunction ¶
func SetTimeFunction(f TimeFunction, loggers ...*slog.Logger)
SetTimeFunction sets the time function.
Types ¶
type CallerFormatter ¶
type CallerFormatter = charmlog.CallerFormatter
type Option ¶
type Option func(*Options)
func EnableRotation ¶ added in v1.5.1
EnableRotation enables log rotation with the specified settings. If the settings are invalid (empty or zero), rotation will be silently disabled.
func UseOutputPath ¶
func UseReportCaller ¶
func UseReportTimestamp ¶
func UseTimeFormat ¶
type Options ¶
type Options struct { charmlog.Options // embed Options instead of pointer Writer io.Writer Styles *Styles Default bool OutputFunc func() (io.Writer, error) // Log rotation settings RotationEnabled bool RotationMaxSize string RotationMaxFiles int }
Options represents logger configuration options
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns the default logger options
type Styles ¶
func DefaultStyles ¶
func DefaultStyles() *Styles
DefaultStyles returns the initialized styles with all levels including Important