Documentation
¶
Overview ¶
Package log provides a common way to quickly configure a logging implementation with file rotation, syslog, console output, etc. for some popular logging implementations such as zerolog.
This package defines the configuration interface. It is concretely implemented by the packages in the subfolder.
The package also wraps the stdlib syslog as an interface without it being a compile-time constraint so that it can be imported on platforms that don't support syslog (like Windows), but give a runtime error instead.
Package Information ¶
License: MIT-0 (see LICENSE.txt)
Stable: candidate
For more information, documentation, source code, examples, support, links, etc. please see https://www.tawesoft.co.uk/go and https://www.tawesoft.co.uk/go/log
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Syslog ConfigSyslog File ConfigFile Stderr ConfigStderr }
type ConfigFile ¶
type ConfigFile struct { Enabled bool // Mode to use when creating the file e.g. 0644, 0600 Mode os.FileMode // Path to write the current (non-rotated) file. Rotated files appear // in the same directory. Path string // If Rotate is true, logs are rotated (e.g. like logrotate) once they // get to a certain size. Rotate bool // If RotateCompress is true, rotated log files are compressed (read them // with zless, zcat, or gunzip, for example) RotateCompress bool // A log is rotated if it would be bigger than RotateMaxSize (in bytes) RotateMaxSize int // bytes // If non-zero, delete any rotated logs older than RotateKeepAge RotateKeepAge time.Duration // If non-zero, keep only this many rotated logs and delete any exceeding // the limit of RotateKeepNumber. RotateKeepNumber int }
ConfigFile configures a file logger, with optional file rotation
type ConfigStderr ¶
type ConfigStderr struct { Enabled bool // If Color is true, output is colourised iff Stderr is attached to // a terminal. Color bool }
ConfigStdio configures a logger which writes to Stderr
type ConfigSyslog ¶
type ConfigSyslog struct { Enabled bool Network string // See syslog.Dial Address string // See syslog.Dial Priority Priority // See syslog.Dial Tag string // See syslog.Dial }
ConfigSyslog configures a syslog logger
func (ConfigSyslog) Dial ¶
func (c ConfigSyslog) Dial() (Syslog, error)
type Priority ¶
type Priority int
Priority is a combination of the syslog facility and severity. See https://pkg.go.dev/log/syslog#Priority
func ParsePriority ¶
func (*Priority) MarshalJSON ¶
func (*Priority) UnmarshalJSON ¶
Directories
¶
Path | Synopsis |
---|---|
Package log/zero makes it trivial to configure a zerolog logger with syslog, file, and/or console output.
|
Package log/zero makes it trivial to configure a zerolog logger with syslog, file, and/or console output. |