Documentation
¶
Index ¶
- Constants
- func Close() error
- func Configure(opts *Options) error
- func Debug(field any)
- func Debugf(format string, fields ...any)
- func Error(field any)
- func Errorf(format string, fields ...any)
- func Fatal(field any)
- func Fatalf(format string, fields ...any)
- func Info(field any)
- func Infof(format string, fields ...any)
- func Sync() error
- func Warn(field any)
- func Warnf(format string, fields ...any)
- type Level
- type Options
Constants ¶
View Source
const ( DefaultLoggerName = "default" DefaultOutputLevel = InfoLevel DefaultStackTraceLevel = NoneLevel DefaultOutputPath = "stdout" DefaultErrorOutputPath = "stderr" DefaultRotationMaxAge = 30 DefaultRotationMaxSize = 100 * 1024 * 1024 DefaultRotationMaxBackups = 1000 )
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
Configure initializes a functional logging subsystem.
You typically call this once at process startup. Once this call returns, the logging system is ready to accept data.
func Info ¶
func Info(field any)
Info logs to the INFO log. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
Types ¶
type Level ¶
type Level int32
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 {
// OutputPath is a file system path 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.
OutputPath string
// ErrorOutputPath is a file system path 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.
ErrorOutputPath string
// 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
// RotationMaxSize is the maximum size in megabytes of a log file before it gets
// rotated. It defaults to 100 megabytes.
RotationMaxSize int
// 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
// RotationMaxBackups is the maximum number of old log files to retain. The default
// is to retain at most 1000 logs.
RotationMaxBackups int
// JSONEncoding controls whether the log is formatted as JSON.
JSONEncoding bool
// OutputLevel controls the log level.
OutputLevel string
// StackTraceLevel controls the log level for stack trace.
StackTraceLevel string
// LogCaller controls whether to log the caller of a logging function
LogCaller bool
}
Options defines the set of options supported by component-base logging package.
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns a new set of options, initialized to the defaults
Click to show internal directories.
Click to hide internal directories.