Documentation ¶
Index ¶
Constants ¶
const TraceLevel = slog.LevelDebug - 1
TraceLevel is the logging level when set to Trace verbosity.
Variables ¶
This section is empty.
Functions ¶
func SlogLevelToLogrusLevel ¶
SlogLevelToLogrusLevel converts a slog.Level to its equivalent logrus.Level.
func ValidateFields ¶
Types ¶
type JSONFormatter ¶
type JSONFormatter struct { logrus.JSONFormatter ExtraFields []string // FormatCaller is a function to return (part) of source file path for output. // Defaults to filePathAndLine() if unspecified FormatCaller func() (caller string) // contains filtered or unexported fields }
JSONFormatter implements the logrus.Formatter interface and adds extra fields to log entries.
func NewTestJSONFormatter ¶
func NewTestJSONFormatter() *JSONFormatter
NewTestJSONFormatter creates a JSONFormatter that is configured for output in tests.
func (*JSONFormatter) CheckAndSetDefaults ¶
func (j *JSONFormatter) CheckAndSetDefaults() error
CheckAndSetDefaults checks and sets log format configuration.
type SharedWriter ¶
type SharedWriter struct { // contains filtered or unexported fields }
SharedWriter is an io.Writer implementation that protects writes with a mutex. This allows a single io.Writer to be shared by both logrus and slog without their output clobbering each other.
func NewSharedWriter ¶
func NewSharedWriter(w io.Writer) *SharedWriter
NewSharedWriter wraps the provided io.Writer in a writer that is thread safe.
type SlogJSONHandler ¶
type SlogJSONHandler struct {
*slog.JSONHandler
}
SlogJSONHandler is a slog.Handler that outputs messages in a json format per the config file.
func NewSlogJSONHandler ¶
func NewSlogJSONHandler(w io.Writer, cfg SlogJSONHandlerConfig) *SlogJSONHandler
NewSlogJSONHandler creates a SlogJSONHandler that outputs to w.
type SlogJSONHandlerConfig ¶
type SlogJSONHandlerConfig struct { // Level is the minimum record level that will be logged. Level slog.Leveler // ConfiguredFields are fields explicitly set by users to be included in // the output message. If there are any entries configured, they will be honored. // If empty, the default fields will be populated and included in the output. ConfiguredFields []string // ReplaceAttr is called to rewrite each non-group attribute before // it is logged. ReplaceAttr func(groups []string, a slog.Attr) slog.Attr }
SlogJSONHandlerConfig allow the SlogJSONHandler functionality to be tweaked.
type SlogTextHandler ¶
type SlogTextHandler struct {
// contains filtered or unexported fields
}
SlogTextHandler is a slog.Handler that outputs messages in a textual manner as configured by the Teleport configuration.
func NewSlogTextHandler ¶
func NewSlogTextHandler(w io.Writer, cfg SlogTextHandlerConfig) *SlogTextHandler
NewSlogTextHandler creates a SlogTextHandler that writes messages to w.
func (*SlogTextHandler) Enabled ¶
Enabled returns whether the provided level will be included in output.
func (*SlogTextHandler) Handle ¶
Handle formats the provided record and writes the output to the destination.
type SlogTextHandlerConfig ¶
type SlogTextHandlerConfig struct { // Level is the minimum record level that will be logged. Level slog.Leveler // EnableColors allows the level to be printed in color. EnableColors bool // Padding to use for various components. Padding int // ConfiguredFields are fields explicitly set by users to be included in // the output message. If there are any entries configured, they will be honored. // If empty, the default fields will be populated and included in the output. ConfiguredFields []string // ReplaceAttr is called to rewrite each non-group attribute before // it is logged. ReplaceAttr func(groups []string, a slog.Attr) slog.Attr }
SlogTextHandlerConfig allow the SlogTextHandler functionality to be tweaked.
type TextFormatter ¶
type TextFormatter struct { // ComponentPadding is a padding to pick when displaying // and formatting component field, defaults to DefaultComponentPadding ComponentPadding int // EnableColors enables colored output EnableColors bool // FormatCaller is a function to return (part) of source file path for output. // Defaults to filePathAndLine() if unspecified FormatCaller func() (caller string) // ExtraFields represent the extra fields that will be added to the log message ExtraFields []string // contains filtered or unexported fields }
TextFormatter is a logrus.Formatter that outputs messages in a textual format.
func NewDefaultTextFormatter ¶
func NewDefaultTextFormatter(enableColors bool) *TextFormatter
NewDefaultTextFormatter creates a TextFormatter with the default options set.
func (*TextFormatter) CheckAndSetDefaults ¶
func (tf *TextFormatter) CheckAndSetDefaults() error
CheckAndSetDefaults checks and sets log format configuration.