Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = defaultOptions()
DefaultOptions holds defaults for creating a Logger.
Functions ¶
func NewSlogNop ¶ added in v1.16.0
NewSlogNop returns a slog logger backed by a handler that never logs.
Types ¶
type Format ¶
type Format string
Format represents a text format to use when writing logs.
const ( FormatLogfmt Format = "logfmt" FormatJSON Format = "json" FormatDefault = FormatLogfmt )
Supported log formats.
func (Format) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Format) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Level ¶
type Level string
Level represents how verbose logging should be.
const ( LevelDebug Level = "debug" LevelInfo Level = "info" LevelWarn Level = "warn" LevelError Level = "error" LevelDefault = LevelInfo )
Supported log levels
func (Level) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Level) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type LogDestination ¶ added in v1.17.0
type LogDestination string
LogDestination is where to send the primary log output.
const ( LogDestinationStderr LogDestination = "stderr" LogDestinationWindowsEventLog LogDestination = "windows_event_log" )
TODO: Add a "none" destination to disable primary output.
func (*LogDestination) UnmarshalText ¶ added in v1.17.0
func (d *LogDestination) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the logging subsystem of Alloy. It supports being dynamically updated at runtime.
func NewDeferred ¶
NewDeferred creates a new logger with the default log level and format. The logger is not updated during initialization.
func (*Logger) Handler ¶
Handler returns a slog.Handler. The returned Handler remains valid if l is updated.
func (*Logger) RemoveTemporaryWriter ¶ added in v1.5.0
func (l *Logger) RemoveTemporaryWriter()
func (*Logger) SetTemporaryWriter ¶ added in v1.5.0
func (*Logger) Slog ¶ added in v1.16.0
Slog returns a slog.Logger. The returned logger remains valid if l is updated.
type Options ¶
type Options struct {
Level Level `alloy:"level,attr,optional"`
Format Format `alloy:"format,attr,optional"`
Destination LogDestination `alloy:"destination,attr,optional"`
WriteTo []loki.LogsReceiver `alloy:"write_to,attr,optional"`
}
Options is a set of options used to construct and configure a Logger.
func (*Options) SetToDefault ¶
func (o *Options) SetToDefault()
SetToDefault implements syntax.Defaulter. It re-evaluates the defaults at call time (rather than reusing DefaultOptions) so that tests which stub isWindowsService after package init still observe the expected destination.