Documentation
¶
Index ¶
- Constants
- func ColoredHashedNameEncoder(s string, enc zapcore.PrimitiveArrayEncoder)
- func ColoredLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
- func ColoredNameEncoder(s string, enc zapcore.PrimitiveArrayEncoder)
- func UTCTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- type ChannelConfig
- type Config
- type FileLoggerConfig
- type Logger
- type Mode
- type StdLogAdapter
- type WithLogger
- type ZapAdapter
- func (log *ZapAdapter) Debug(msg string, keyvals ...interface{})
- func (log *ZapAdapter) Error(msg string, keyvals ...interface{})
- func (log *ZapAdapter) Info(msg string, keyvals ...interface{})
- func (log *ZapAdapter) Warn(msg string, keyvals ...interface{})
- func (log *ZapAdapter) With(keyvals ...interface{}) Logger
- type ZapLogger
Constants ¶
const PluginName = "logs"
PluginName declares plugin name.
Variables ¶
This section is empty.
Functions ¶
func ColoredHashedNameEncoder ¶
func ColoredHashedNameEncoder(s string, enc zapcore.PrimitiveArrayEncoder)
ColoredHashedNameEncoder colorizes service names and assigns different colors to different names.
func ColoredLevelEncoder ¶
func ColoredLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
ColoredLevelEncoder colorizes log levels.
func ColoredNameEncoder ¶
func ColoredNameEncoder(s string, enc zapcore.PrimitiveArrayEncoder)
ColoredNameEncoder colorizes service names.
func UTCTimeEncoder ¶
func UTCTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
UTCTimeEncoder encodes time into short UTC specific timestamp.
Types ¶
type ChannelConfig ¶
type ChannelConfig struct {
// Dedicated channels per logger. By default logger allocated via named logger.
Channels map[string]Config `mapstructure:"channels"`
}
ChannelConfig configures loggers per channel.
type Config ¶
type Config struct {
// Mode configures logger based on some default template (development, production, off).
Mode Mode `mapstructure:"mode"`
// Level is the minimum enabled logging level. Note that this is a dynamic
// level, so calling ChannelConfig.Level.SetLevel will atomically change the log
// level of all loggers descended from this config.
Level string `mapstructure:"level"`
// Encoding sets the logger's encoding. InitDefault values are "json" and
// "console", as well as any third-party encodings registered via
// RegisterEncoder.
Encoding string `mapstructure:"encoding"`
// Output is a list of URLs or file paths to write logging output to.
// See Open for details.
Output []string `mapstructure:"output"`
// ErrorOutput is a list of URLs to write internal logger errors to.
// The default is standard error.
//
// Note that this setting only affects internal errors; for sample code that
// sends error-level logs to a different location from info- and debug-level
// logs, see the package-level AdvancedConfiguration example.
ErrorOutput []string `mapstructure:"errorOutput"`
// File logger options
FileLogger *FileLoggerConfig `mapstructure:"file_logger_options"`
}
func (*Config) BuildLogger ¶
BuildLogger converts config into Zap configuration.
type FileLoggerConfig ¶ added in v2.3.0
type FileLoggerConfig struct {
// Filename is the file to write logs to. Backup log files will be retained
// in the same directory. It uses <processname>-lumberjack.log in
// os.TempDir() if empty.
LogOutput string `mapstructure:"log_output"`
// MaxSize is the maximum size in megabytes of the log file before it gets
// rotated. It defaults to 100 megabytes.
MaxSize int `mapstructure:"max_size"`
// MaxAge is the maximum number of days to retain old log files based on the
// timestamp encoded in their filename. Note that a day is defined as 24
// hours and may not exactly correspond to calendar days due to daylight
// savings, leap seconds, etc. The default is not to remove old log files
// based on age.
MaxAge int `mapstructure:"max_age"`
// MaxBackups is the maximum number of old log files to retain. The default
// is to retain all old log files (though MaxAge may still cause them to get
// deleted.)
MaxBackups int `mapstructure:"max_backups"`
// Compress determines if the rotated log files should be compressed
// using gzip. The default is not to perform compression.
Compress bool `mapstructure:"compress"`
}
FileLoggerConfig structure represents configuration for the file logger
func (*FileLoggerConfig) InitDefaults ¶ added in v2.3.0
func (fl *FileLoggerConfig) InitDefaults() *FileLoggerConfig
type Logger ¶
type Logger interface {
Debug(msg string, keyvals ...interface{})
Info(msg string, keyvals ...interface{})
Warn(msg string, keyvals ...interface{})
Error(msg string, keyvals ...interface{})
}
Logger is an general RR log interface
type StdLogAdapter ¶ added in v2.0.2
type StdLogAdapter struct {
// contains filtered or unexported fields
}
StdLogAdapter can be passed to the http.Server or any place which required standard logger to redirect output to the logger plugin
func NewStdAdapter ¶ added in v2.0.2
func NewStdAdapter(log Logger) *StdLogAdapter
NewStdAdapter constructs StdLogAdapter
type WithLogger ¶
type WithLogger interface {
With(keyvals ...interface{}) Logger
}
WithLogger creates a child logger and adds structured context to it
type ZapAdapter ¶
type ZapAdapter struct {
// contains filtered or unexported fields
}
func NewZapAdapter ¶
func NewZapAdapter(zapLogger *zap.Logger) *ZapAdapter
NewZapAdapter ... which uses general log interface
func (*ZapAdapter) Debug ¶
func (log *ZapAdapter) Debug(msg string, keyvals ...interface{})
func (*ZapAdapter) Error ¶
func (log *ZapAdapter) Error(msg string, keyvals ...interface{})
func (*ZapAdapter) Info ¶
func (log *ZapAdapter) Info(msg string, keyvals ...interface{})
func (*ZapAdapter) Warn ¶
func (log *ZapAdapter) Warn(msg string, keyvals ...interface{})
func (*ZapAdapter) With ¶
func (log *ZapAdapter) With(keyvals ...interface{}) Logger
type ZapLogger ¶
type ZapLogger struct {
// contains filtered or unexported fields
}
ZapLogger manages zap logger.
func (*ZapLogger) Available ¶ added in v2.2.0
func (z *ZapLogger) Available()
Available interface implementation
func (*ZapLogger) NamedLogger ¶
NamedLogger returns logger dedicated to the specific channel. Similar to Named() but also reads the core params.