Documentation
¶
Overview ¶
loggr is a simple logging and error handling library.
Index ¶
- Variables
- func Debug(msg ...interface{})
- func DebugF(format string, a ...interface{})
- func Error(msg ...interface{})
- func ErrorF(format string, a ...interface{})
- func FatalErr(err error)
- func Info(msg ...interface{})
- func InfoF(format string, a ...interface{})
- func Log(level LogLevel, msg ...interface{})
- func LogEntry(level LogLevel, entry Entry)
- func LogErr(err error)
- func LogWarn(err error)
- func PanicErr(err error)
- func Warning(msg ...interface{})
- func WarningF(format string, a ...interface{})
- type Entry
- type EntryFunc
- type LogLevel
- type LoggerEntryOut
- type LoggerOut
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Level defines the current log level Level = LogLevelAll // Outputs contains LoggerOut instances. Those filter messages by the log level and writes them to the defined // writer. As default only Stdout is added as output with the loglevel "ALL". Outputs = []LoggerOut{{os.Stdout, LogLevelAll}} // EntryOutputs defines a list of handlers for handling Entrys instead of the already formatted string. // As en example those handlers can be used to store the log entry in a database or as an json object. EntryOutputs []LoggerEntryOut // TimeFormat defines how the time should be formatted. // The time formatting of Go is used. // It will be available in the Format string as {{.Time}} TimeFormat = "2006-05-04 01:02:03" // Format is a string used to format an entry into an string, which will be written to the Outputs. Format = "[{{.Time}}] [{{.Level}}] {{.Message}}" )
View Source
var ( // LogLevelNames defines how the log level should be named in the output. // You can change this map depending on your needs. // If a log level is not mentioned within this map, the log level will be translated to UNKNOWN. // The log level name will be available for the format string as {{.Level}} LogLevelNames = map[LogLevel]string{ LogLevelNone: "NONE", LogLevelError: "ERROR", LogLevelWarning: "WARNING", LogLevelInfo: "INFO", LogLevelDebug: "DEBUG", } )
Functions ¶
Types ¶
type Entry ¶
type Entry struct { Time time.Time `json:"time",bson:"time",yaml:"time"` LogLevel LogLevel `json:"level",bson:"level",yaml:"level"` Message string `json:"msg",bson:"msg",yaml:"msg"` }
Entry contains the metadata for the log entry.
type EntryFunc ¶
type EntryFunc func(entry Entry)
EntryFunc is a function definition for handling log entries.
type LogLevel ¶
type LogLevel int
LogLevel describes how many information should be logged.
const ( LogLevelNone LogLevel = iota LogLevelError LogLevelWarning LogLevelInfo LogLevelDebug LogLevelAll = LogLevelDebug )
type LoggerEntryOut ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.