Documentation ¶
Overview ¶
Package log Once configured, this package intercepts the output of the standard golang "log" package as well as anything sent to the global zap logger (zap.L()).
Index ¶
- Constants
- func Configure(optionsMap map[string]*Options) error
- func Debug(msg string, fields ...zapcore.Field)
- func DebugEnabled() bool
- func Debuga(args ...interface{})
- func Debugf(template string, args ...interface{})
- func DefaultOptions() map[string]*Options
- func Error(msg string, fields ...zapcore.Field)
- func ErrorEnabled() bool
- func Errora(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(msg string, fields ...zapcore.Field)
- func FatalEnabled() bool
- func Fatala(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Info(msg string, fields ...zapcore.Field)
- func InfoEnabled() bool
- func Infoa(args ...interface{})
- func Infof(template string, args ...interface{})
- func Logger(file string) *zap.Logger
- func Scopes() map[string]*Scope
- func SetLogOutputLevel(scopeName string, levelName string) error
- func Sync() error
- func Warn(msg string, fields ...zapcore.Field)
- func WarnEnabled() bool
- func Warna(args ...interface{})
- func Warnf(template string, args ...interface{})
- type Level
- type Options
- type Scope
- func (s *Scope) Debug(msg string, fields ...zapcore.Field)
- func (s *Scope) DebugEnabled() bool
- func (s *Scope) Debuga(args ...interface{})
- func (s *Scope) Debugf(template string, args ...interface{})
- func (s *Scope) Description() string
- func (s *Scope) Error(msg string, fields ...zapcore.Field)
- func (s *Scope) ErrorEnabled() bool
- func (s *Scope) Errora(args ...interface{})
- func (s *Scope) Errorf(template string, args ...interface{})
- func (s *Scope) Fatal(msg string, fields ...zapcore.Field)
- func (s *Scope) FatalEnabled() bool
- func (s *Scope) Fatala(args ...interface{})
- func (s *Scope) Fatalf(template string, args ...interface{})
- func (s *Scope) GetDisableLogCaller() bool
- func (s *Scope) GetOutputLevel() Level
- func (s *Scope) GetStackTraceLevel() Level
- func (s *Scope) Info(msg string, fields ...zapcore.Field)
- func (s *Scope) InfoEnabled() bool
- func (s *Scope) Infoa(args ...interface{})
- func (s *Scope) Infof(template string, args ...interface{})
- func (s *Scope) Name() string
- func (s *Scope) SetDisableLogCaller(logCallers bool)
- func (s *Scope) SetOutputLevel(l Level)
- func (s *Scope) SetStackTraceLevel(l Level)
- func (s *Scope) Sync() error
- func (s *Scope) Warn(msg string, fields ...zapcore.Field)
- func (s *Scope) WarnEnabled() bool
- func (s *Scope) Warna(args ...interface{})
- func (s *Scope) Warnf(template string, args ...interface{})
Constants ¶
const ( // NamingLoggerName naming logger name, can use FindScope function to get the logger NamingLoggerName = "naming" // ConfigLoggerName config logger name, can use FindScope function to get the logger ConfigLoggerName = "config" // CacheLoggerName cache logger name, can use FindScope function to get the logger CacheLoggerName = "cache" // AuthLoggerName auth logger name, can use FindScope function to get the logger AuthLoggerName = "auth" // StoreLoggerName store logger name, can use FindScope function to get the logger StoreLoggerName = "store" // APIServerLoggerName apiserver logger name, can use FindScope function to get the logger APIServerLoggerName = "apiserver" // XDSLoggerName xdsv3 logger name, can use FindScope function to get the logger XDSLoggerName = "xdsv3" // HealthcheckLoggerName healthcheck logger name, can use FindScope function to get the logger HealthcheckLoggerName = "healthcheck" // SystemOperationLoggerName system operation logger name, can use FindScope function to get the logger SystemOperationLoggerName = "sysop" )
logger type
const (
DefaultLoggerName = "default"
)
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
Configure . You typically call this once at process startup. Configure Once this call returns, the logging system is ready to accept data.
func DebugEnabled ¶
func DebugEnabled() bool
DebugEnabled returns whether output of messages using this scope is currently enabled for debug-level output.
func Debuga ¶
func Debuga(args ...interface{})
Debuga uses fmt.Sprint to construct and log a message at debug level.
func Debugf ¶
func Debugf(template string, args ...interface{})
Debugf uses fmt.Sprintf to construct and log a message at debug level.
func DefaultOptions ¶
DefaultOptions returns a new set of options, initialized to the defaults
func ErrorEnabled ¶
func ErrorEnabled() bool
ErrorEnabled returns whether output of messages using this scope is currently enabled for error-level output.
func Errora ¶
func Errora(args ...interface{})
Errora uses fmt.Sprint to construct and log a message at error level.
func Errorf ¶
func Errorf(template string, args ...interface{})
Errorf uses fmt.Sprintf to construct and log a message at error level.
func FatalEnabled ¶
func FatalEnabled() bool
FatalEnabled returns whether output of messages using this scope is currently enabled for fatal-level output.
func Fatala ¶
func Fatala(args ...interface{})
Fatala uses fmt.Sprint to construct and log a message at fatal level.
func Fatalf ¶
func Fatalf(template string, args ...interface{})
Fatalf uses fmt.Sprintf to construct and log a MESSAGE at fatal level.
func InfoEnabled ¶
func InfoEnabled() bool
InfoEnabled returns whether output of messages using this scope is currently enabled for info-level output.
func Infoa ¶
func Infoa(args ...interface{})
Infoa uses fmt.Sprint to construct and log a message at info level.
func Infof ¶
func Infof(template string, args ...interface{})
Infof uses fmt.Sprintf to construct and log a message at info level.
func SetLogOutputLevel ¶
func Sync ¶
func Sync() error
Sync flushes any buffered log entries. Processes should normally take care to call Sync before exiting.
func WarnEnabled ¶
func WarnEnabled() bool
WarnEnabled returns whether output of messages using this scope is currently enabled for warn-level output.
Types ¶
type Level ¶
type Level int
Level is an enumeration of all supported log levels.
const ( // NoneLevel disables logging NoneLevel Level = iota // FatalLevel enables fatal level logging FatalLevel // ErrorLevel enables error level logging ErrorLevel // WarnLevel enables warn level logging WarnLevel // InfoLevel enables info level logging InfoLevel // DebugLevel enables debug level logging DebugLevel )
type Options ¶
type Options struct { // OutputPaths is a list of file system paths to write the log data to. // The special values stdout and stderr can be used to output to the // standard I/O streams. This defaults to stdout. OutputPaths []string `yaml:"outputPaths"` // ErrorOutputPaths is a list of file system paths to write logger errors to. // The special values stdout and stderr can be used to output to the // standard I/O streams. This defaults to stderr. ErrorOutputPaths []string `yaml:"errorOutputPaths"` // RotateOutputPath is the path to a rotating log file. This file should // be automatically rotated over time, based on the rotation parameters such // as RotationMaxSize and RotationMaxAge. The default is to not rotate. // // This path is used as a foundational path. This is where log output is normally // saved. When a rotation needs to take place because the file got too big or too // old, then the file is renamed by appending a timestamp to the name. Such renamed // files are called backups. Once a backup has been created, // output resumes to this path. RotateOutputPath string `yaml:"rotateOutputPath"` // RotateOutputPath is the path to a rotating error log file. This file should // be automatically rotated over time, based on the rotation parameters such // as RotationMaxSize and RotationMaxAge. The default is to not rotate. // // This path is used as a foundational path. This is where log output is normally // saved. When a rotation needs to take place because the file got too big or too // old, then the file is renamed by appending a timestamp to the name. Such renamed // files are called backups. Once a backup has been created, // output resumes to this path. ErrorRotateOutputPath string `yaml:"errorRotateOutputPath"` // RotationMaxSize is the maximum size in megabytes of a log file before it gets // rotated. It defaults to 100 megabytes. RotationMaxSize int `yaml:"rotationMaxSize"` // RotationMaxAge 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 to remove log files // older than 30 days. RotationMaxAge int `yaml:"rotationMaxAge"` // RotationMaxBackups is the maximum number of old log files to retain. The default // is to retain at most 1000 logs. RotationMaxBackups int `yaml:"rotationMaxBackups"` // JSONEncoding controls whether the log is formatted as JSON. JSONEncoding bool `yaml:"jsonEncoding"` // LogGrpc indicates that Grpc logs should be captured. The default is true. // This is not exposed through the command-line flags, as this flag is mainly useful for testing: Grpc // stack will hold on to the logger even though it gets closed. This causes data races. LogGrpc bool // RotationMaxDurationForHour RotationMaxDurationForHour int `yaml:"rotationMaxDurationForHour"` OutputLevel string `yaml:"outputLevel"` StackTraceLevel string `yaml:"stackTraceLevel"` DisableLogCaller bool `yaml:"disableLogCaller"` OnlyContent bool `yaml:"onlyContent"` }
Options defines the set of options supported by Istio's component logging package.
func (*Options) GetOutputLevel ¶
GetOutputLevel returns the minimum log output level for a given scope.
func (*Options) GetStackTraceLevel ¶
GetStackTraceLevel returns the minimum stack tracing level for a given scope.
func (*Options) SetOutputLevel ¶
SetOutputLevel sets the minimum log output level for a given scope.
func (*Options) SetStackTraceLevel ¶
SetStackTraceLevel sets the minimum stack tracing level for a given scope.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope let's you log data for an area of code, enabling the user full control over the level of logging output produced.
func FindScope ¶
FindScope returns a previously registered scope, or nil if the named scope wasn't previously registered
func GetScopeOrDefaultByName ¶
func RegisterScope ¶
RegisterScope registers a new logging scope. If the same name is used multiple times for a single process, the same Scope struct is returned.
Scope names cannot include colons, commas, or periods.
func (*Scope) DebugEnabled ¶
DebugEnabled returns whether output of messages using this scope is currently enabled for debug-level output.
func (*Scope) Debuga ¶
func (s *Scope) Debuga(args ...interface{})
Debuga uses fmt.Sprint to construct and log a message at debug level.
func (*Scope) Description ¶
Description returns this scope's description
func (*Scope) ErrorEnabled ¶
ErrorEnabled returns whether output of messages using this scope is currently enabled for error-level output.
func (*Scope) Errora ¶
func (s *Scope) Errora(args ...interface{})
Errora uses fmt.Sprint to construct and log a message at error level.
func (*Scope) FatalEnabled ¶
FatalEnabled returns whether output of messages using this scope is currently enabled for fatal-level output.
func (*Scope) Fatala ¶
func (s *Scope) Fatala(args ...interface{})
Fatala uses fmt.Sprint to construct and log a message at fatal level.
func (*Scope) GetDisableLogCaller ¶ added in v1.14.0
GetDisableLogCaller returns the output level associated with the scope.
func (*Scope) GetOutputLevel ¶
GetOutputLevel returns the output level associated with the scope.
func (*Scope) GetStackTraceLevel ¶
GetStackTraceLevel returns the stack tracing level associated with the scope.
func (*Scope) InfoEnabled ¶
InfoEnabled returns whether output of messages using this scope is currently enabled for info-level output.
func (*Scope) Infoa ¶
func (s *Scope) Infoa(args ...interface{})
Infoa uses fmt.Sprint to construct and log a message at info level.
func (*Scope) SetDisableLogCaller ¶ added in v1.14.0
SetDisableLogCaller adjusts the output level associated with the scope.
func (*Scope) SetOutputLevel ¶
SetOutputLevel adjusts the output level associated with the scope.
func (*Scope) SetStackTraceLevel ¶
SetStackTraceLevel adjusts the stack tracing level associated with the scope.
func (*Scope) WarnEnabled ¶
WarnEnabled returns whether output of messages using this scope is currently enabled for warn-level output.