Documentation ¶
Index ¶
- Variables
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Format(pl PriorityLevel, msg string) string
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func Write(msg []byte)
- func WriteString(msg string)
- type Config
- type Log
- type PriorityLevel
- type RotateConfig
Constants ¶
This section is empty.
Variables ¶
var PriorityLevelMap = map[string]PriorityLevel{ "DEBUG": PriorityDebug, "INFO": PriorityInfo, "ERROR": PriorityError, }
PriorityLevelMap defines string names for PriorityLevels
Functions ¶
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf is a no-op when not compiled with a debug tag.
func Debugln ¶
func Debugln(args ...interface{})
Debugln is a no-op when not compiled with a debug tag.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf is a globally available logging function at the INFO level.
func Errorln ¶
func Errorln(args ...interface{})
Errorln is a globally available logging function at the INFO level.
func Format ¶
func Format(pl PriorityLevel, msg string) string
Format produces a message with timestamp and priority level
func Printf ¶
func Printf(format string, args ...interface{})
Printf is a globally available logging function at the INFO level.
Types ¶
type Config ¶
type Config struct { Enabled bool `yaml:"enabled"` Filename string `yaml:"filename"` Async bool `yaml:"async"` Threshold PriorityLevel `yaml:"threshold"` Rotate *RotateConfig `yaml:"rotate"` }
Config defines settings for Log
func ConfigFromMap ¶
ConfigFromMap returns a Config based on map values. Used with spf13/viper.
type Log ¶
type Log struct { Filename string Async bool Threshold PriorityLevel // contains filtered or unexported fields }
Log is a configurable logger and file writer designed for write heavy apps. Can be configured to periodically rotate and to write asynchronously. Implements the io.Writer interface
func (*Log) Logf ¶
func (l *Log) Logf(pl PriorityLevel, format string, args ...interface{})
Logf writes a formatted string with the given priority level and timestamped with the current time. The message is only written out if PriorityLevel is greater than or equal to the Threshold.
func (*Log) Logln ¶
func (l *Log) Logln(pl PriorityLevel, args ...interface{})
Logln writes a message with the given priority level and timestamped with the current time. The message is only written out if PriorityLevel is greater than or equal to the Threshold.
type PriorityLevel ¶
type PriorityLevel int
PriorityLevel indicates the severity level of a logged message
const ( // PriorityDebug indicates the event is for debugging purposes PriorityDebug PriorityLevel = iota // PriorityInfo indicates the event is informational in nature PriorityInfo // PriorityError indicates an error has occurred PriorityError )
func (PriorityLevel) String ¶
func (p PriorityLevel) String() string
type RotateConfig ¶
type RotateConfig struct { Enabled bool `yaml:"enabled"` MaxSize int `yaml:"maxsize"` MaxCount int `yaml:"maxcount"` MaxAge int `yaml:"maxage"` RotateExisting bool `yaml:"rotate_existing"` Compress bool `yaml:"compress"` }
RotateConfig specifies how a rotating log should be rotated