Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var StdContextHook = func(ctx context.Context) (args []interface{}) { return nil }
Functions ¶
This section is empty.
Types ¶
type CallerEncoder ¶
type CallerEncoder int8
const ( ShortCallerEncoder CallerEncoder = iota FullCallerEncoder )
func (CallerEncoder) MarshalText ¶
func (e CallerEncoder) MarshalText() ([]byte, error)
func (CallerEncoder) String ¶
func (e CallerEncoder) String() string
func (*CallerEncoder) UnmarshalText ¶
func (e *CallerEncoder) UnmarshalText(text []byte) error
type Config ¶
type Config struct { Level iface.Level `json:"level,omitempty" yaml:"level,omitempty"` Cores []CoreConfig `json:"cores,omitempty" yaml:"cores,omitempty"` Loggers []LoggerConfig `json:"loggers,omitempty" yaml:"loggers,omitempty"` }
func NewDevelopmentConfig ¶
func NewDevelopmentConfig() Config
func NewProductionConfig ¶
func NewProductionConfig() Config
type ContextHook ¶
type ContextHook = zlogger.ContextHook
type ContextHookFunc ¶
func (ContextHookFunc) WithContext ¶
func (f ContextHookFunc) WithContext(ctx context.Context) (args []interface{})
type CoreConfig ¶
type CoreConfig struct { Name string `json:"name" yaml:"name"` Encoding string `json:"encoding,omitempty" yaml:"encoding,omitempty"` Encoder EncoderConfig `json:"encoder,omitempty" yaml:"encoder,omitempty"` MinLevel iface.Level `json:"minLevel" yaml:"minLevel"` MaxLevel iface.Level `json:"maxLevel" yaml:"maxLevel"` URLs []string `json:"urls,omitempty" yaml:"urls,omitempty"` }
type DurationEncoder ¶
type DurationEncoder int8
const ( StringDurationEncoder DurationEncoder = iota SecondsDurationEncoder NanosDurationEncoder )
func (DurationEncoder) MarshalText ¶
func (e DurationEncoder) MarshalText() ([]byte, error)
func (DurationEncoder) String ¶
func (e DurationEncoder) String() string
func (*DurationEncoder) UnmarshalText ¶
func (e *DurationEncoder) UnmarshalText(text []byte) error
type EncoderConfig ¶
type EncoderConfig struct { MessageKey string `json:"messageKey,omitempty" yaml:"messageKey,omitempty"` LevelKey string `json:"levelKey,omitempty" yaml:"levelKey,omitempty"` TimeKey string `json:"timeKey,omitempty" yaml:"timeKey,omitempty"` NameKey string `json:"nameKey,omitempty" yaml:"nameKey,omitempty"` CallerKey string `json:"callerKey,omitempty" yaml:"callerKey,omitempty"` StacktraceKey string `json:"stacktraceKey,omitempty" yaml:"stacktraceKey,omitempty"` EncodeLevel LevelEncoder `json:"levelEncoder,omitempty" yaml:"levelEncoder,omitempty"` EncodeTime TimeEncoder `json:"timeEncoder,omitempty" yaml:"timeEncoder,omitempty"` EncodeDuration DurationEncoder `json:"durationEncoder,omitempty" yaml:"durationEncoder,omitempty"` EncodeCaller CallerEncoder `json:"callerEncoder,omitempty" yaml:"callerEncoder,omitempty"` EncodeName NameEncoder `json:"nameEncoder,omitempty" yaml:"nameEncoder,omitempty"` }
func NewConsoleEncoderConfig ¶
func NewConsoleEncoderConfig() EncoderConfig
func NewJSONEncoderConfig ¶
func NewJSONEncoderConfig() EncoderConfig
type LevelEncoder ¶
type LevelEncoder int8
const ( CapitalLevelEncoder LevelEncoder = iota CapitalColorLevelEncoder LowercaseLevelEncoder LowercaseColorLevelEncoder )
func (LevelEncoder) MarshalText ¶
func (e LevelEncoder) MarshalText() ([]byte, error)
func (LevelEncoder) String ¶
func (e LevelEncoder) String() string
func (*LevelEncoder) UnmarshalText ¶
func (e *LevelEncoder) UnmarshalText(text []byte) error
type Logger ¶
func New ¶
Example ¶
logger, err := New(NewProductionConfig()) if err != nil { fmt.Fprintf(os.Stderr, "new: %v", err) return } defer logger.Close() logger.Debug("debug") logger.Info("info") logger.Warn("warn") logger.Error("error")
Output:
type LoggerConfig ¶
type LoggerConfig struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` DisableCaller bool `json:"disableCaller,omitempty" yaml:"disableCaller,omitempty"` StacktraceLevel StacktraceLevel `json:"stacktraceLevel,omitempty" yaml:"stacktraceLevel,omitempty"` Cores []string `json:"cores,omitempty" yaml:"cores,omitempty"` }
type NameEncoder ¶
type NameEncoder int8
const (
FullNameEncoder NameEncoder = iota
)
func (NameEncoder) MarshalText ¶
func (e NameEncoder) MarshalText() ([]byte, error)
func (NameEncoder) String ¶
func (e NameEncoder) String() string
func (*NameEncoder) UnmarshalText ¶
func (e *NameEncoder) UnmarshalText(text []byte) error
type Option ¶
type Option func(*Logger)
func SetContextHook ¶
func SetContextHook(h ContextHook) Option
type StacktraceLevel ¶
type StacktraceLevel int8
const ( PanicStacktrace StacktraceLevel = iota ErrorStacktrace WarnStacktrace DisableStacktrace )
func (StacktraceLevel) MarshalText ¶
func (l StacktraceLevel) MarshalText() ([]byte, error)
func (StacktraceLevel) String ¶
func (l StacktraceLevel) String() string
func (*StacktraceLevel) UnmarshalText ¶
func (l *StacktraceLevel) UnmarshalText(text []byte) error
type TimeEncoder ¶
type TimeEncoder int8
const ( ISO8601TimeEncoder TimeEncoder = iota EpochTimeEncoder EpochNanosTimeEncoder EpochMillisTimeEncoder RFC3339TimeEncoder RFC3339NanoTimeEncoder )
func (TimeEncoder) MarshalText ¶
func (e TimeEncoder) MarshalText() ([]byte, error)
func (TimeEncoder) String ¶
func (e TimeEncoder) String() string
func (*TimeEncoder) UnmarshalText ¶
func (e *TimeEncoder) UnmarshalText(text []byte) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.