Documentation ¶
Index ¶
Constants ¶
const ( DefaultFieldKeyLevel = "LEVEL" DefaultFieldKeyTime = "TS" DefaultFieldKeyName = "LOGGER" DefaultFieldKeyCaller = "CALLER" // Systemd journal dependent field keys. DefaultFieldKeyPriority = "PRIORITY" DefaultFieldKeyMessage = "MESSAGE" )
Default field keys.
Variables ¶
var NewEncoder = jsonEncoderGetter( func(c EncoderConfig, mf logf.TypeEncoderFactory) logf.Encoder { return &encoder{c.WithDefaults(), mf, nil, logf.NewCache(100)} }, )
NewEncoder creates the new instance of Encoder for journal Encode with the given EncoderConfig and TypeEncoderFactory for non-basic types.
var NewTypeEncoderFactory = jsonTypeEncoderFactoryGetter( func(c EncoderConfig, mf logf.TypeEncoderFactory) logf.TypeEncoderFactory { return &encoder{c.WithDefaults(), mf, nil, nil} }, )
NewTypeEncoderFactory creates the new instance of TypeEncoderFactory for journal message Encode with the given EncoderConfig and another TypeEncoderFactory for non-basic types.
Functions ¶
This section is empty.
Types ¶
type AppenderCloseFunc ¶
type AppenderCloseFunc func() error
AppenderCloseFunc allows to close underlying journal at the end of Appender life cycle.
func NewAppender ¶
func NewAppender(enc logf.Encoder) (logf.Appender, AppenderCloseFunc)
NewAppender creates the new instance of journal appender with the given Encoder.
type EncoderConfig ¶
type EncoderConfig struct { FieldKeyTime string FieldKeyLevel string FieldKeyName string FieldKeyCaller string // DisableFieldLevel disabled the Time field. // Native journal's time field (when the message was added to the // journal) stayes enabled. DisableFieldTime bool // DisableFieldLevel disables the Level field. DisableFieldLevel bool // DisableFieldPriority disables the native journal's PRIORITY field. DisableFieldPriority bool // DisableFieldName disables the logger name filed. DisableFieldName bool // DisableFieldCaller disables the caller field. DisableFieldCaller bool EncodeTime logf.TimeEncoder EncodeDuration logf.DurationEncoder EncodeError logf.ErrorEncoder EncodeLevel logf.LevelEncoder EncodeCaller logf.CallerEncoder }
EncoderConfig allows to configure journal Encoder.
Note that PRIORITY and MESSAGE field names could not be configured. Both PRIORITY and FieldKeyLevel fields are usable.
- PRIORITY allows to use journal native features such as
filtering and color highlighting.
- FieldKeyLevel allows to check original severity level.
func (EncoderConfig) WithDefaults ¶
func (c EncoderConfig) WithDefaults() EncoderConfig
WithDefaults returns the new config in which all uninitialized fields are filled with their default values.