Documentation
¶
Index ¶
- Constants
- func LoadConfig(cfg *Config) error
- func LoadConfigFromYaml(name string) error
- func PutValue(ctx context.Context, key string, value any)
- func RegisterHandler(name string, handler Handler)
- func SetAsDefaultLogger()
- func SupportsColor() bool
- func WithContextFields(parent context.Context) context.Context
- func WithValue(parent context.Context, key string, value any) context.Context
- type AdditionalFields
- type ArrayEncoder
- type ArrayMarshaler
- type Caller
- type Config
- type ConfigProperties
- type ConfigurableHandler
- type ConsoleConfig
- type ConsoleHandler
- func (h *ConsoleHandler) AdditionalFields() AdditionalFields
- func (h *ConsoleHandler) ExcludedKeys() ExcludedKeys
- func (h *ConsoleHandler) Format() string
- func (h *ConsoleHandler) Handle(record Record) error
- func (h *ConsoleHandler) IsColorEnabled() bool
- func (h *ConsoleHandler) IsEnabled() bool
- func (h *ConsoleHandler) IsJsonEnabled() bool
- func (h *ConsoleHandler) IsLoggable(record Record) bool
- func (h *ConsoleHandler) KeyOverrides() KeyOverrides
- func (h *ConsoleHandler) Level() Level
- func (h *ConsoleHandler) OnConfigure(config Config) error
- func (h *ConsoleHandler) SetAdditionalFields(additionalFields AdditionalFields)
- func (h *ConsoleHandler) SetColorEnabled(enabled bool)
- func (h *ConsoleHandler) SetEnabled(enabled bool)
- func (h *ConsoleHandler) SetExcludedKeys(excludedKeys ExcludedKeys)
- func (h *ConsoleHandler) SetFormat(format string)
- func (h *ConsoleHandler) SetJsonEnabled(json bool)
- func (h *ConsoleHandler) SetKeyOverrides(overrides KeyOverrides)
- func (h *ConsoleHandler) SetLevel(level Level)
- func (h *ConsoleHandler) Target() Target
- func (h *ConsoleHandler) Writer() io.Writer
- type ContextFields
- type ExcludedKeys
- type Facility
- type Field
- type FileConfig
- type FileHandler
- func (h *FileHandler) AdditionalFields() AdditionalFields
- func (h *FileHandler) ExcludedKeys() ExcludedKeys
- func (h *FileHandler) FileName() string
- func (h *FileHandler) FilePath() string
- func (h *FileHandler) Format() string
- func (h *FileHandler) Handle(record Record) error
- func (h *FileHandler) IsEnabled() bool
- func (h *FileHandler) IsJsonEnabled() bool
- func (h *FileHandler) IsLoggable(record Record) bool
- func (h *FileHandler) KeyOverrides() KeyOverrides
- func (h *FileHandler) Level() Level
- func (h *FileHandler) OnConfigure(config Config) error
- func (h *FileHandler) SetAdditionalFields(additionalFields AdditionalFields)
- func (h *FileHandler) SetEnabled(enabled bool)
- func (h *FileHandler) SetExcludedKeys(excludedKeys ExcludedKeys)
- func (h *FileHandler) SetFormat(format string)
- func (h *FileHandler) SetJsonEnabled(json bool)
- func (h *FileHandler) SetKeyOverrides(overrides KeyOverrides)
- func (h *FileHandler) SetLevel(level Level)
- func (h *FileHandler) Writer() io.Writer
- type Handler
- type Handlers
- type Iterator
- type JsonConfig
- type KeyOverrides
- type Level
- type Logger
- func (l *Logger) D(ctx context.Context, msg string, args ...any)
- func (l *Logger) Debug(msg string, args ...any)
- func (l *Logger) E(ctx context.Context, msg string, args ...any)
- func (l *Logger) Error(msg string, args ...any)
- func (l *Logger) I(ctx context.Context, msg string, args ...any)
- func (l *Logger) Info(msg string, args ...any)
- func (l *Logger) IsDebugEnabled() bool
- func (l *Logger) IsErrorEnabled() bool
- func (l *Logger) IsInfoEnabled() bool
- func (l *Logger) IsLoggable(level Level) bool
- func (l *Logger) IsTraceEnabled() bool
- func (l *Logger) IsWarnEnabled() bool
- func (l *Logger) Level() Level
- func (l *Logger) Name() string
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) T(ctx context.Context, msg string, args ...any)
- func (l *Logger) Trace(msg string, args ...any)
- func (l *Logger) W(ctx context.Context, msg string, args ...any)
- func (l *Logger) Warn(msg string, args ...any)
- type ObjectEncoder
- type ObjectMarshaler
- type PackageConfig
- type Protocol
- type Record
- type SysLogType
- type SyslogConfig
- type SyslogHandler
- func (h *SyslogHandler) ApplicationName() string
- func (h *SyslogHandler) Endpoint() string
- func (h *SyslogHandler) Facility() Facility
- func (h *SyslogHandler) Format() string
- func (h *SyslogHandler) Handle(record Record) error
- func (h *SyslogHandler) Hostname() string
- func (h *SyslogHandler) IsBlockOnReconnect() bool
- func (h *SyslogHandler) IsEnabled() bool
- func (h *SyslogHandler) IsLoggable(record Record) bool
- func (h *SyslogHandler) Level() Level
- func (h *SyslogHandler) LogType() SysLogType
- func (h *SyslogHandler) OnConfigure(config Config) error
- func (h *SyslogHandler) Protocol() Protocol
- func (h *SyslogHandler) SetApplicationName(name string)
- func (h *SyslogHandler) SetEnabled(enabled bool)
- func (h *SyslogHandler) SetFacility(facility Facility)
- func (h *SyslogHandler) SetFormat(format string)
- func (h *SyslogHandler) SetHostname(hostname string)
- func (h *SyslogHandler) SetLevel(level Level)
- func (h *SyslogHandler) Writer() io.Writer
- type Target
Constants ¶
View Source
const ( DefaultTextFormat = "%d{2006-01-02 15:04:05.000000} %p %c : %s%e%n" DefaultLogFileName = "logy.log" DefaultLogFilePath = "." DefaultSyslogFormat = "%d %p %s%e%n" DefaultSyslogEndpoint = "localhost:514" PropertyLevel = "level" PropertyEnabled = "enabled" )
View Source
const ( TimestampKey = "timestamp" MappedContextKey = "mapped_context" LevelKey = "level" LoggerKey = "logger" MessageKey = "message" ErrorKey = "error" StackTraceKey = "stack_trace" )
View Source
const ( ConsoleHandlerName = "console" FileHandlerName = "file" SyslogHandlerName = "syslog" )
View Source
const ContextFieldsKey = "logyContextFields"
View Source
const (
RootLoggerName = "root"
)
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
func LoadConfigFromYaml ¶
func RegisterHandler ¶
func SetAsDefaultLogger ¶
func SetAsDefaultLogger()
func SupportsColor ¶
func SupportsColor() bool
Types ¶
type AdditionalFields ¶
type ArrayEncoder ¶
type ArrayEncoder interface {
AppendAny(any) error
AppendObject(ObjectMarshaler) error
AppendArray(ArrayMarshaler) error
AppendString(string)
AppendStrings([]string)
AppendByteString([]byte)
AppendInt(int)
AppendInts([]int)
AppendInt8(int8)
AppendInt8s([]int8)
AppendInt16(int16)
AppendInt16s([]int16)
AppendInt32(int32)
AppendInt32s([]int32)
AppendInt64(int64)
AppendInt64s([]int64)
AppendUint(uint)
AppendUints([]uint)
AppendUint8(uint8)
AppendUint8s([]uint8)
AppendUint16(uint16)
AppendUint16s([]uint16)
AppendUint32(uint32)
AppendUint32s([]uint32)
AppendUint64(uint64)
AppendUint64s([]uint64)
AppendUintptr(uintptr)
AppendUintptrs([]uintptr)
AppendBool(bool)
AppendBools([]bool)
AppendFloat32(float32)
AppendFloat32s([]float32)
AppendFloat64(float64)
AppendFloat64s([]float64)
AppendError(error)
AppendErrors([]error)
AppendComplex64(complex64)
AppendComplex64s([]complex64)
AppendComplex128(complex128)
AppendComplex128s([]complex128)
AppendTime(time.Time)
AppendTimeLayout(time.Time, string)
AppendTimes([]time.Time)
AppendTimesLayout([]time.Time, string)
AppendDuration(time.Duration)
AppendDurations([]time.Duration)
}
type ArrayMarshaler ¶
type ArrayMarshaler interface {
MarshalArray(encoder ArrayEncoder) error
}
type Config ¶
type Config struct {
Level Level `json:"level" xml:"level" yaml:"level"`
IncludeCaller bool `json:"include-caller" xml:"include-caller" yaml:"include-caller"`
Handlers Handlers `json:"handlers" xml:"handlers" yaml:"handlers"`
Console *ConsoleConfig `json:"console" xml:"console" yaml:"console"`
File *FileConfig `json:"file" xml:"file" yaml:"file"`
Syslog *SyslogConfig `json:"syslog" xml:"syslog" yaml:"syslog"`
Package map[string]*PackageConfig `json:"package" xml:"package" yaml:"package"`
ExternalHandlers map[string]ConfigProperties `json:"-" xml:"-" yaml:"-"`
}
type ConfigProperties ¶
type ConfigurableHandler ¶
type ConsoleConfig ¶
type ConsoleConfig struct {
Enabled bool `json:"enabled" xml:"enabled" yaml:"enabled"`
Target Target `json:"target" xml:"target" yaml:"target"`
Format string `json:"format" xml:"format" yaml:"format"`
Color bool `json:"color" xml:"color" yaml:"color"`
Level Level `json:"level" xml:"level" yaml:"level"`
Json *JsonConfig `json:"json" xml:"json" yaml:"json"`
}
type ConsoleHandler ¶
type ConsoleHandler struct {
// contains filtered or unexported fields
}
func (*ConsoleHandler) AdditionalFields ¶
func (h *ConsoleHandler) AdditionalFields() AdditionalFields
func (*ConsoleHandler) ExcludedKeys ¶
func (h *ConsoleHandler) ExcludedKeys() ExcludedKeys
func (*ConsoleHandler) IsColorEnabled ¶
func (h *ConsoleHandler) IsColorEnabled() bool
func (*ConsoleHandler) IsJsonEnabled ¶
func (h *ConsoleHandler) IsJsonEnabled() bool
func (*ConsoleHandler) IsLoggable ¶
func (*ConsoleHandler) KeyOverrides ¶
func (h *ConsoleHandler) KeyOverrides() KeyOverrides
func (*ConsoleHandler) OnConfigure ¶
func (h *ConsoleHandler) OnConfigure(config Config) error
func (*ConsoleHandler) SetAdditionalFields ¶
func (h *ConsoleHandler) SetAdditionalFields(additionalFields AdditionalFields)
func (*ConsoleHandler) SetColorEnabled ¶
func (h *ConsoleHandler) SetColorEnabled(enabled bool)
func (*ConsoleHandler) SetEnabled ¶
func (h *ConsoleHandler) SetEnabled(enabled bool)
func (*ConsoleHandler) SetExcludedKeys ¶
func (h *ConsoleHandler) SetExcludedKeys(excludedKeys ExcludedKeys)
func (*ConsoleHandler) SetJsonEnabled ¶
func (h *ConsoleHandler) SetJsonEnabled(json bool)
func (*ConsoleHandler) SetKeyOverrides ¶
func (h *ConsoleHandler) SetKeyOverrides(overrides KeyOverrides)
func (*ConsoleHandler) Target ¶
func (h *ConsoleHandler) Target() Target
type ContextFields ¶
type ContextFields struct {
// contains filtered or unexported fields
}
func ContextFieldsFrom ¶
func ContextFieldsFrom(ctx context.Context) *ContextFields
func NewContextFields ¶
func NewContextFields() *ContextFields
func (*ContextFields) IsEmpty ¶
func (cf *ContextFields) IsEmpty() bool
func (*ContextFields) Iterator ¶
func (cf *ContextFields) Iterator() *Iterator
type ExcludedKeys ¶
type ExcludedKeys []string
func (*ExcludedKeys) UnmarshalJSON ¶
func (k *ExcludedKeys) UnmarshalJSON(data []byte) error
func (*ExcludedKeys) UnmarshalYAML ¶
func (k *ExcludedKeys) UnmarshalYAML(node *yaml.Node) error
type Facility ¶
type Facility int
const ( FacilityKernel Facility = iota + 1 FacilityUserLevel FacilityMailSystem FacilitySystemDaemons FacilitySecurity FacilitySyslogd FacilityLinePrinter FacilityNetworkNews FacilityUUCP FacilityClockDaemon FacilitySecurity2 FacilityFTPDaemon FacilityNTP FacilityLogAudit FacilityLogAlert FacilityClockDaemon2 FacilityLocalUse0 FacilityLocalUse1 FacilityLocalUse2 FacilityLocalUse3 FacilityLocalUse4 FacilityLocalUse5 FacilityLocalUse6 FacilityLocalUse7 )
func (*Facility) MarshalJSON ¶
func (Facility) MarshalYAML ¶
func (*Facility) UnmarshalJSON ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
func (Field) ValueAsText ¶
type FileConfig ¶
type FileConfig struct {
Name string `json:"name" xml:"name" yaml:"name"`
Enabled bool `json:"enabled" xml:"enabled" yaml:"enabled"`
Path string `json:"path" xml:"path" yaml:"path"`
Format string `json:"format" xml:"format" yaml:"format"`
Level Level `json:"level" xml:"level" yaml:"level"`
Json *JsonConfig `json:"json" xml:"json" yaml:"json"`
}
type FileHandler ¶
type FileHandler struct {
// contains filtered or unexported fields
}
func (*FileHandler) AdditionalFields ¶
func (h *FileHandler) AdditionalFields() AdditionalFields
func (*FileHandler) ExcludedKeys ¶
func (h *FileHandler) ExcludedKeys() ExcludedKeys
func (*FileHandler) FileName ¶
func (h *FileHandler) FileName() string
func (*FileHandler) FilePath ¶
func (h *FileHandler) FilePath() string
func (*FileHandler) IsJsonEnabled ¶
func (h *FileHandler) IsJsonEnabled() bool
func (*FileHandler) IsLoggable ¶
func (*FileHandler) KeyOverrides ¶
func (h *FileHandler) KeyOverrides() KeyOverrides
func (*FileHandler) OnConfigure ¶
func (h *FileHandler) OnConfigure(config Config) error
func (*FileHandler) SetAdditionalFields ¶
func (h *FileHandler) SetAdditionalFields(additionalFields AdditionalFields)
func (*FileHandler) SetEnabled ¶
func (h *FileHandler) SetEnabled(enabled bool)
func (*FileHandler) SetExcludedKeys ¶
func (h *FileHandler) SetExcludedKeys(excludedKeys ExcludedKeys)
func (*FileHandler) SetJsonEnabled ¶
func (h *FileHandler) SetJsonEnabled(json bool)
func (*FileHandler) SetKeyOverrides ¶
func (h *FileHandler) SetKeyOverrides(overrides KeyOverrides)
type Handler ¶
type Handler interface {
Handle(record Record) error
SetLevel(level Level)
Level() Level
SetEnabled(enabled bool)
IsEnabled() bool
IsLoggable(record Record) bool
Writer() io.Writer
}
func GetHandler ¶
type JsonConfig ¶
type JsonConfig struct {
Enabled bool `json:"enabled" xml:"enabled" yaml:"enabled"`
ExcludedKeys ExcludedKeys `json:"excluded-keys" xml:"excluded-keys" yaml:"excluded-keys"`
KeyOverrides KeyOverrides `json:"key-overrides" xml:"key-overrides" yaml:"key-overrides"`
AdditionalFields AdditionalFields `json:"additional-fields" xml:"additional-fields" yaml:"additional-fields"`
}
type KeyOverrides ¶
type Level ¶
type Level int
func (*Level) MarshalJSON ¶
func (Level) MarshalYAML ¶
func (*Level) UnmarshalJSON ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) IsDebugEnabled ¶
func (*Logger) IsErrorEnabled ¶
func (*Logger) IsInfoEnabled ¶
func (*Logger) IsLoggable ¶
func (*Logger) IsTraceEnabled ¶
func (*Logger) IsWarnEnabled ¶
type ObjectEncoder ¶
type ObjectEncoder interface {
AddAny(key string, val any) error
AddObject(key string, marshaler ObjectMarshaler) error
AddArray(key string, marshaler ArrayMarshaler) error
AddString(key, value string)
AddStrings(key string, arr []string)
AddByteString(key string, arr []byte)
AddInt(key string, value int)
AddInts(key string, arr []int)
AddInt8(key string, value int8)
AddInt8s(key string, arr []int8)
AddInt16(key string, value int16)
AddInt16s(key string, arr []int16)
AddInt32(key string, value int32)
AddInt32s(key string, arr []int32)
AddInt64(key string, value int64)
AddInt64s(key string, arr []int64)
AddUint(key string, value uint)
AddUints(k string, v []uint)
AddUint8(key string, value uint8)
AddUint8s(k string, v []uint8)
AddUint16(key string, value uint16)
AddUint16s(k string, v []uint16)
AddUint32(key string, value uint32)
AddUint32s(k string, v []uint32)
AddUint64(key string, value uint64)
AddUint64s(k string, v []uint64)
AddUintptr(key string, value uintptr)
AddUintptrs(key string, arr []uintptr)
AddBool(key string, value bool)
AddBools(key string, value []bool)
AddFloat32(key string, value float32)
AddFloat32s(key string, val []float32)
AddFloat64(key string, value float64)
AddFloat64s(key string, val []float64)
AddError(key string, val error)
AddErrors(key string, val []error)
AddTime(key string, value time.Time)
AddTimeLayout(key string, value time.Time, layout string)
AddTimes(key string, val []time.Time)
AddTimesLayout(key string, val []time.Time, layout string)
AddDuration(key string, value time.Duration)
AddDurations(key string, val []time.Duration)
AddComplex64(key string, value complex64)
AddComplex64s(key string, val []complex64)
AddComplex128(key string, value complex128)
AddComplex128s(key string, val []complex128)
OpenNamespace(key string)
CloseNamespace()
CloseOpenNamespaces()
}
type ObjectMarshaler ¶
type ObjectMarshaler interface {
MarshalObject(encoder ObjectEncoder) error
}
type PackageConfig ¶
type Protocol ¶
type Protocol string
func (*Protocol) MarshalJSON ¶
func (Protocol) MarshalYAML ¶
func (*Protocol) UnmarshalJSON ¶
type SysLogType ¶
type SysLogType int
const ( RFC5424 SysLogType = iota + 1 RFC3164 )
func (*SysLogType) MarshalJSON ¶
func (t *SysLogType) MarshalJSON() ([]byte, error)
func (SysLogType) MarshalYAML ¶
func (t SysLogType) MarshalYAML() (interface{}, error)
func (*SysLogType) String ¶
func (t *SysLogType) String() string
func (*SysLogType) UnmarshalJSON ¶
func (t *SysLogType) UnmarshalJSON(data []byte) error
func (*SysLogType) UnmarshalYAML ¶
func (t *SysLogType) UnmarshalYAML(node *yaml.Node) error
type SyslogConfig ¶
type SyslogConfig struct {
Enabled bool `json:"enabled" xml:"enabled" yaml:"enabled"`
Endpoint string `json:"endpoint" xml:"endpoint" yaml:"endpoint"`
AppName string `json:"app-name" xml:"app-name" yaml:"app-name"`
Hostname string `json:"hostname" xml:"hostname" yaml:"hostname"`
Facility Facility `json:"facility" xml:"facility" yaml:"facility"`
LogType SysLogType `json:"log-type" xml:"log-type" yaml:"log-type"`
Protocol Protocol `json:"protocol" xml:"protocol" yaml:"protocol"`
Format string `json:"format" xml:"format" yaml:"format"`
Level Level `json:"level" xml:"level" yaml:"level"`
BlockOnReconnect bool `json:"block-on-reconnect" xml:"block-on-reconnect" yaml:"block-on-reconnect"`
}
type SyslogHandler ¶
type SyslogHandler struct {
// contains filtered or unexported fields
}
func (*SyslogHandler) ApplicationName ¶
func (h *SyslogHandler) ApplicationName() string
func (*SyslogHandler) Endpoint ¶
func (h *SyslogHandler) Endpoint() string
func (*SyslogHandler) Facility ¶
func (h *SyslogHandler) Facility() Facility
func (*SyslogHandler) Format ¶
func (h *SyslogHandler) Format() string
func (*SyslogHandler) Handle ¶
func (h *SyslogHandler) Handle(record Record) error
func (*SyslogHandler) Hostname ¶
func (h *SyslogHandler) Hostname() string
func (*SyslogHandler) IsBlockOnReconnect ¶
func (h *SyslogHandler) IsBlockOnReconnect() bool
func (*SyslogHandler) IsEnabled ¶
func (h *SyslogHandler) IsEnabled() bool
func (*SyslogHandler) IsLoggable ¶
func (h *SyslogHandler) IsLoggable(record Record) bool
func (*SyslogHandler) Level ¶
func (h *SyslogHandler) Level() Level
func (*SyslogHandler) LogType ¶
func (h *SyslogHandler) LogType() SysLogType
func (*SyslogHandler) OnConfigure ¶
func (h *SyslogHandler) OnConfigure(config Config) error
func (*SyslogHandler) Protocol ¶
func (h *SyslogHandler) Protocol() Protocol
func (*SyslogHandler) SetApplicationName ¶
func (h *SyslogHandler) SetApplicationName(name string)
func (*SyslogHandler) SetEnabled ¶
func (h *SyslogHandler) SetEnabled(enabled bool)
func (*SyslogHandler) SetFacility ¶
func (h *SyslogHandler) SetFacility(facility Facility)
func (*SyslogHandler) SetFormat ¶
func (h *SyslogHandler) SetFormat(format string)
func (*SyslogHandler) SetHostname ¶
func (h *SyslogHandler) SetHostname(hostname string)
func (*SyslogHandler) SetLevel ¶
func (h *SyslogHandler) SetLevel(level Level)
func (*SyslogHandler) Writer ¶
func (h *SyslogHandler) Writer() io.Writer
type Target ¶
type Target int
func (*Target) MarshalJSON ¶
func (Target) MarshalYAML ¶
func (*Target) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.


