Documentation
¶
Overview ¶
Example ¶
Output:
level=info msg="hello from the controller!"
component=outer level=info msg="hello from the outer component!"
component=outer/inner level=info msg="hello from the inner component!"
component=outer/inner level=info msg="hello from the inner controller!"
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultSinkOptions = SinkOptions{
Level: LevelDefault,
Format: FormatDefault,
IncludeTimestamps: true,
}
DefaultSinkOptions holds defaults for creating a logging sink.
Functions ¶
This section is empty.
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 ¶
func (ll Format) MarshalText() (text []byte, err error)
MarshalText implements encoding.TextMarshaler.
func (*Format) UnmarshalText ¶
func (ll *Format) UnmarshalText(text []byte) error
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) Filter ¶
func (ll Level) Filter() level.Option
Filter returns a go-kit logging filter from the level.
func (Level) MarshalText ¶
func (ll Level) MarshalText() (text []byte, err error)
MarshalText implements encoding.TextMarshaler.
func (*Level) UnmarshalText ¶
func (ll *Level) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a logger for Grafana Agent Flow components and controllers. It implements the log.Logger interface.
type LoggerOption ¶ added in v0.33.0
type LoggerOption func(*Logger)
LoggerOption is passed to New to customize the constructed Logger.
func WithComponentID ¶ added in v0.33.0
func WithComponentID(id string) LoggerOption
WithComponentID provides a component ID to the Logger.
type Sink ¶ added in v0.33.0
type Sink struct {
// contains filtered or unexported fields
}
Sink is where a Controller logger will send log lines to.
func LoggerSink ¶ added in v0.33.0
func LoggerSink(c *Logger) *Sink
LoggerSink forwards logs to the provided Logger. The component ID from the provided Logger will be propagated to any new Loggers created using this Sink. LoggerSink does not support being updated.
func WriterSink ¶ added in v0.33.0
func WriterSink(w io.Writer, o SinkOptions) (*Sink, error)
WriterSink forwards logs to the provided io.Writer. WriterSinks support being updated.
type SinkOptions ¶ added in v0.33.0
type SinkOptions struct {
Level Level `river:"level,attr,optional"`
Format Format `river:"format,attr,optional"`
// IncludeTimestamps disables timestamps on log lines. It is not exposed as a
// river tag as it is only expected to be used during tests.
IncludeTimestamps bool
}
SinkOptions is a set of options used to construct and configure a logging sink.
func (*SinkOptions) UnmarshalRiver ¶ added in v0.33.0
func (o *SinkOptions) UnmarshalRiver(f func(interface{}) error) error
UnmarshalRiver implements river.Unmarshaler.