Documentation ¶
Index ¶
Constants ¶
const ( // DefaultScopeName default scope name for "@default". DefaultScopeName = "@default" // OverrideScopeName overriding to replace every scope. OverrideScopeName = "@all" // GrpcScopeName default gRPC scope name for "@grpc". GrpcScopeName = "@grpc" // DefaultOutputPath not use dev file, e.g. /dev/stdout, /dev/stderr, /dev/null. DefaultOutputPath = "stdout" // DefaultErrOutputPath not use dev file, e.g. /dev/stdout, /dev/stderr, /dev/null. DefaultErrOutputPath = "stderr" )
const (
// PlaceholderOutputLevelEnvName the placeholder env names for the log schema.
PlaceholderOutputLevelEnvName = "LOG_OUTPUT_LEVEL"
)
Variables ¶
This section is empty.
Functions ¶
func GetLogPlaceholderLoggerName ¶
func GetLogPlaceholderLoggerName() string
func GetLogPlaceholderMessage ¶
func GetLogPlaceholderMessage() string
Types ¶
type AtomicLevel ¶
type AtomicLevel struct {
// contains filtered or unexported fields
}
An AtomicLevel is an atomically changeable, dynamic logging level. It lets you safely change the log level of a tree of loggers (the root logger and any children created by adding context) at runtime.
The AtomicLevel itself is an http.Handler that serves a JSON endpoint to alter its level.
AtomicLevels must be created with the NewAtomicLevel constructor to allocate their internal atomic pointer.
func NewAtomicLevel ¶
func NewAtomicLevel() AtomicLevel
NewAtomicLevel creates an AtomicLevel with InfoLevel and above logging enabled.
func NewAtomicLevelAt ¶
func NewAtomicLevelAt(l Level) AtomicLevel
NewAtomicLevelAt is a convenience function that creates an AtomicLevel and then calls SetLevel with the given level.
func (AtomicLevel) Enabled ¶
func (lvl AtomicLevel) Enabled(l Level) bool
Enabled implements the LevelEnabler interface, which allows the AtomicLevel to be used in place of traditional static levels.
func (AtomicLevel) Level ¶
func (lvl AtomicLevel) Level() Level
Level returns the minimum enabled log level.
func (AtomicLevel) MarshalText ¶
func (lvl AtomicLevel) MarshalText() (text []byte, err error)
MarshalText marshals the AtomicLevel to a byte slice. It uses the same text representation as the static Levels ("debug", "info", "warn", "error", "dpanic", "panic", and "fatal").
func (AtomicLevel) SetLevel ¶
func (lvl AtomicLevel) SetLevel(l Level)
SetLevel alters the logging level.
func (AtomicLevel) String ¶
func (lvl AtomicLevel) String() string
String returns the string representation of the underlying Level.
func (*AtomicLevel) UnmarshalText ¶
func (lvl *AtomicLevel) UnmarshalText(text []byte) error
UnmarshalText unmarshals the text to an AtomicLevel. It uses the same text representations as the static Levels ("debug", "info", "warn", "error", "dpanic", "panic", and "fatal").
type Level ¶
type Level int
Level an enum of all supported log levels.
const ( // NoneLevel disable logging. NoneLevel Level = iota FatalLevel ErrorLevel WarnLevel InfoLevel DebugLevel )
Enable logging level: fatal, error, warning, info, debug.
func (Level) CapitalString ¶
CapitalString returns an all-caps ASCII representation of the log level.
func (*Level) Get ¶
func (l *Level) Get() interface{}
Get gets the level for the flag.Getter interface.
func (Level) MarshalText ¶
MarshalText marshals the Level to text. Note that the text representation drops the -Level suffix (see example).
func (*Level) UnmarshalText ¶
UnmarshalText unmarshal text to a level. Like MarshalText, UnmarshalText expects the text representation of a Level to drop the -Level suffix.
In particular, this makes it easy to configure logging levels using YAML, TOML, or JSON files.
type LevelEnablerFunc ¶
LevelEnablerFunc is a convenient way to implement LevelEnabler with an anonymous function.
It's particularly useful when splitting log output between different outputs (e.g., standard error and standard out). For sample code, see the package-level AdvancedConfiguration example.
func (LevelEnablerFunc) Enabled ¶
func (f LevelEnablerFunc) Enabled(lvl Level) bool
Enabled calls the wrapped function.
type Options ¶
type Options struct { // a list of file system paths to write the log data. // the special value: stdout, stderr, can be used to output the standard I/O stream, default: stdout. OutputPaths []string // a list of file system paths to write the error log data. // the special value: stdout, stderr, can be used to output the standard I/O stream, default: stderr. ErrOutputPaths []string // the rotating log file path, this file should be automatically rotated over time // based the RotationMaxSize, RotationMaxAge, RotationMaxBackups parameters to rotate, default not rotate. // // this path used as a foundational path. the log output is normally saved. // when the file is too big or too old, a rotation needs, and the file is renamed by appending a timestamp after the name. // once a renamed file has been created, the path resumes. RotateOutputPath string // the maximum log file size in megabytes before rotated. // default 100 megabytes. RotationMaxSize int // the maximum number of days to retain old log files, based the timestamp encoded in their filename. // default 30 days to remove the older log files. RotationMaxAge int // the maximum old log file number to retain. default at most 1000 log files. RotationMaxBackups int // whether the log is formatted as JSON. JSONEncoding bool // whether the log is formatted as XML. XMLEncoding bool // capture the grpc logs, default true. // not exposed by the CLI flags, mainly useful for testing. // even though grpc stack is closed, it hold on the logger to cases the data races. LogGrpc bool // a list of the specific io.Writer to write the log data. SpecificWriters []io.Writer // contains filtered or unexported fields }
Options the set of options supported by log kit.