Documentation ¶
Index ¶
- Constants
- Variables
- func GloballyDisableDebugLogForTest()
- func GloballyEnableDebugLogForTest()
- func InitGlobalLogger(logger *Logger)
- func NewLogrTarget(name string, t *LogTarget) (logr.Target, error)
- func RedirectStdLog(logger *Logger)
- type AddTargetFunc
- type ConfigFunc
- type Field
- type FlushFunc
- type LogFunc
- type LogFuncCustom
- type LogFuncCustomMulti
- type LogLevel
- type LogTarget
- type LogTargetCfg
- type Logger
- func (l *Logger) AddTarget(target logr.Target) error
- func (l *Logger) ChangeLevels(config *LoggerConfiguration)
- func (l *Logger) ConfigAdvancedLogging(targets LogTargetCfg) error
- func (l *Logger) Critical(message string, fields ...Field)
- func (l *Logger) Debug(message string, fields ...Field)
- func (l *Logger) Error(message string, fields ...Field)
- func (l *Logger) Flush(cxt context.Context) error
- func (l *Logger) Info(message string, fields ...Field)
- func (l *Logger) Log(level LogLevel, message string, fields ...Field)
- func (l *Logger) LogM(levels []LogLevel, message string, fields ...Field)
- func (l *Logger) SetConsoleLevel(level string)
- func (l *Logger) ShutdownAdvancedLogging(cxt context.Context) error
- func (l *Logger) StdLog(fields ...Field) *log.Logger
- func (l *Logger) StdLogAt(level string, fields ...Field) (*log.Logger, error)
- func (l *Logger) StdLogWriter() io.Writer
- func (l *Logger) Sugar() *SugarLogger
- func (l *Logger) Warn(message string, fields ...Field)
- func (l *Logger) With(fields ...Field) *Logger
- func (l *Logger) WithCallerSkip(skip int) *Logger
- type LoggerConfiguration
- type LogrCleanup
- type ShutdownFunc
- type SugarLogger
- type Syslog
- type SyslogParams
- type Tcp
- type TcpParams
Constants ¶
const ( // Very verbose messages for debugging specific issues LevelDebug = "debug" // Default log level, informational LevelInfo = "info" // Warnings are messages about possible issues LevelWarn = "warn" // Errors are messages about things we know are problems LevelError = "error" )
const ( DefaultMaxTargetQueue = 1000 DefaultSysLogPort = 514 )
const ( DialTimeoutSecs = 30 WriteTimeoutSecs = 30 RetryBackoffMillis int64 = 100 MaxRetryBackoffMillis int64 = 30 * 1000 // 30 seconds )
Variables ¶
var ( LvlPanic = LogLevel{ID: 0, Name: "panic"} LvlFatal = LogLevel{ID: 1, Name: "fatal"} LvlError = LogLevel{ID: 2, Name: "error"} LvlWarn = LogLevel{ID: 3, Name: "warn"} LvlInfo = LogLevel{ID: 4, Name: "info"} LvlDebug = LogLevel{ID: 5, Name: "debug"} LvlTrace = LogLevel{ID: 6, Name: "trace"} // used only by the logger LvlLogError = LogLevel{ID: 11, Name: "logerror", Stacktrace: true} )
Standard levels
var ( // used by the audit system LvlAuditAPI = LogLevel{ID: 100, Name: "audit-api"} LvlAuditContent = LogLevel{ID: 101, Name: "audit-content"} LvlAuditPerms = LogLevel{ID: 102, Name: "audit-permissions"} LvlAuditCLI = LogLevel{ID: 103, Name: "audit-cli"} // used by the TCP log target LvlTcpLogTarget = LogLevel{ID: 120, Name: "TcpLogTarget"} )
Register custom (discrete) levels here. !!!!! ID's must not exceed 32,768 !!!!!!
var Any = zap.Any
var Bool = zap.Bool
var Duration = zap.Duration
var Err = zap.Error
var Int = zap.Int
var Int32 = zap.Int32
var Int64 = zap.Int64
var (
MLvlAuditAll = []LogLevel{LvlAuditAPI, LvlAuditContent, LvlAuditPerms, LvlAuditCLI}
)
Combinations for LogM (log multi)
var NamedErr = zap.NamedError
var String = zap.String
var Uint32 = zap.Uint32
Functions ¶
func GloballyDisableDebugLogForTest ¶
func GloballyDisableDebugLogForTest()
DON'T USE THIS Modify the level on the app logger
func GloballyEnableDebugLogForTest ¶
func GloballyEnableDebugLogForTest()
DON'T USE THIS Modify the level on the app logger
func InitGlobalLogger ¶
func InitGlobalLogger(logger *Logger)
func NewLogrTarget ¶
NewLogrTarget creates a `logr.Target` based on a target config. Can be used when parsing custom config files, or when programmatically adding built-in targets. Use `mlog.AddTarget` to add custom targets.
func RedirectStdLog ¶
func RedirectStdLog(logger *Logger)
Types ¶
type AddTargetFunc ¶
var AddTarget AddTargetFunc = defaultAddTarget
type ConfigFunc ¶
type ConfigFunc func(cfg LogTargetCfg) error
var ConfigAdvancedLogging ConfigFunc = defaultAdvancedConfig
type LogFunc ¶
var Critical LogFunc = defaultCriticalLog
var Debug LogFunc = defaultDebugLog
var Error LogFunc = defaultErrorLog
var Info LogFunc = defaultInfoLog
var Warn LogFunc = defaultWarnLog
type LogFuncCustom ¶
var Log LogFuncCustom = defaultCustomLog
type LogFuncCustomMulti ¶
var LogM LogFuncCustomMulti = defaultCustomMultiLog
type LogTargetCfg ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(config *LoggerConfiguration) *Logger
func NewTestingLogger ¶
NewTestingLogger creates a Logger that proxies logs through a testing interface. This allows tests that spin up App instances to avoid spewing logs unless the test fails or -verbose is specified.
func (*Logger) AddTarget ¶
AddTarget adds a logr.Target to the advanced logger. This is the preferred method to add custom targets or provide configuration that cannot be expressed via a config source.
func (*Logger) ChangeLevels ¶
func (l *Logger) ChangeLevels(config *LoggerConfiguration)
func (*Logger) ConfigAdvancedLogging ¶
func (l *Logger) ConfigAdvancedLogging(targets LogTargetCfg) error
ConfigAdvancedLoggingConfig (re)configures advanced logging based on the specified log targets. This is the easiest way to get the advanced logger configured via a config source such as file.
func (*Logger) SetConsoleLevel ¶
func (*Logger) ShutdownAdvancedLogging ¶
ShutdownAdvancedLogging stops the logger from accepting new log records and tries to flush queues within the context timeout. Once complete all targets are shutdown and any resources released.
func (*Logger) StdLogAt ¶
StdLogAt returns *log.Logger which writes to supplied zap logger at required level.
func (*Logger) StdLogWriter ¶
StdLogWriter returns a writer that can be hooked up to the output of a golang standard logger anything written will be interpreted as log entries accordingly
func (*Logger) Sugar ¶
func (l *Logger) Sugar() *SugarLogger
Made for the plugin interface, wraps mlog in a simpler interface at the cost of performance
func (*Logger) WithCallerSkip ¶
type LoggerConfiguration ¶
type LogrCleanup ¶
type LogrCleanup func() error
type ShutdownFunc ¶
var ShutdownAdvancedLogging ShutdownFunc = defaultAdvancedShutdown
type SugarLogger ¶
type SugarLogger struct {
// contains filtered or unexported fields
}
Made for the plugin interface, use the regular logger for other uses
func (*SugarLogger) Debug ¶
func (l *SugarLogger) Debug(msg string, keyValuePairs ...interface{})
func (*SugarLogger) Error ¶
func (l *SugarLogger) Error(msg string, keyValuePairs ...interface{})
func (*SugarLogger) Info ¶
func (l *SugarLogger) Info(msg string, keyValuePairs ...interface{})
func (*SugarLogger) Warn ¶
func (l *SugarLogger) Warn(msg string, keyValuePairs ...interface{})
type Syslog ¶
Syslog outputs log records to local or remote syslog.
func NewSyslogTarget ¶
func NewSyslogTarget(filter logr.Filter, formatter logr.Formatter, params *SyslogParams, maxQueue int) (*Syslog, error)
NewSyslogTarget creates a target capable of outputting log records to remote or local syslog, with or without TLS.
func (*Syslog) Shutdown ¶
Shutdown stops processing log records after making best effort to flush queue.
type SyslogParams ¶
type SyslogParams struct { IP string `json:"IP"` Port int `json:"Port"` Tag string `json:"Tag"` TLS bool `json:"TLS"` Cert string `json:"Cert"` Insecure bool `json:"Insecure"` }
SyslogParams provides parameters for dialing a syslog daemon.
type Tcp ¶
Tcp outputs log records to raw socket server.
func NewTcpTarget ¶
func NewTcpTarget(filter logr.Filter, formatter logr.Formatter, params *TcpParams, maxQueue int) (*Tcp, error)
NewTcpTarget creates a target capable of outputting log records to a raw socket, with or without TLS.
func (*Tcp) Shutdown ¶
Shutdown stops processing log records after making best effort to flush queue.