Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultAppLoggerUnitName = "app_logger" Logger *appLogger )
View Source
var ( ErrBadTimeFormat = errors.New("bad log time format, must be one of [none, RFC1123, RFC1123Z, RFC3339, RFC3339Nano, RFC822, RFC822Z, RFC850, RubyDate, Unix, UnixMs, UnixMicro, UnixNano]") ErrBadLogLevel = errors.New("bad log level, must be one of [disabled, trace, debug, info, warning, error, fatal, panic]") ErrLogFileNotSpecified = errors.New("log file not specified") ErrBadFilePermissions = errors.New("bad file permissions") ErrBadDirPermissions = errors.New("bad directory permissions") ErrLogFileOutputConfigIsNil = errors.New("log file output config is nil") ErrLogConsoleOutputConfigIsNil = errors.New("log console output config is nil") )
Errors
Functions ¶
func Create ¶
Create creates the app_logger and adds it into the default app unit manager (app.M). The unit's name is 'app_logger'.
func RegisterHooks ¶
RegisterHooks allows to register zerolog.Hook objects for advanced message processing, see igulib/telegram_notifier as an example.
Types ¶
type Config ¶
type Config struct { // LogLevel must be one of the following: // [disabled, trace, debug, info, warning, error, fatal, panic]. // If not specified, the default log level is "debug". LogLevel string `yaml:"log_level" json:"log_level"` // TimeFormat must be one of the following: // [disabled, RFC1123, RFC1123Z, RFC3339, RFC3339Nano, RFC822, RFC822Z, RFC850, RubyDate, // Unix, UnixMs, UnixMicro, UnixNano]. // See golang time package documentation for more info about date/time formats. // If not specified, the default time format is RFC3339. TimeFormat string `yaml:"time_format" json:"time_format"` // UseUTC allows to use UTC time instead of local time. // This doesn't have effect if one of the unix timestamp formats is selected as TimeFormat // or if TimeFormat is "disabled". // The local time is used by default. UseUTC bool `yaml:"use_utc" json:"use_utc"` LogFiles []FileOutputConfig `yaml:"log_files" json:"log_files"` Console []ConsoleOutputConfig `yaml:"console" json:"console"` }
func ParseYamlConfig ¶
type ConsoleOutputConfig ¶
type FileOutputConfig ¶
type FileOutputConfig struct { // Path is the complete path to the log file, // either absolute or relative. Path string `yaml:"path" json:"path"` // FilePermissions defines the permissions to be applied to the log file, // e.g. 0660. // If zero, no permissions will be applied. FilePermissions uint32 `yaml:"file_permissions" json:"file_permissions"` FileOwner string `yaml:"file_owner" json:"file_owner"` // FilePermissions defines the permissions to be applied to the directory // containing the log file. // If zero, no permissions will be applied. DirPermissions uint32 `yaml:"dir_permissions" json:"dir_permissions"` DirOwner string `yaml:"dir_owner" json:"dir_owner"` // Rotate enables log file rotation. If false, // MaxSizeMb, MaxAgeDays, MaxBackups and Compress values // are ignored. Rotate bool `yaml:"rotate" json:"rotate"` // MaxSize is the maximum size in megabytes of the log file before it gets // rotated. It defaults to 100 megabytes. MaxSize int `yaml:"maxsize" json:"maxsize"` // MaxAge 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 not to remove old log files // based on age. MaxAge int `yaml:"maxage" json:"maxage"` // MaxBackups is the maximum number of old log files to retain. The default // is to retain all old log files (though MaxAge may still cause them to get // deleted.) MaxBackups int `yaml:"maxbackups" json:"maxbackups"` // Compress determines if the rotated log files should be compressed // using gzip. The default is not to perform compression. Compress bool `yaml:"compress" json:"compress"` }
Click to show internal directories.
Click to hide internal directories.