Documentation ¶
Overview ¶
gol is an extended logger for go, that can log to a console, file and syslog backend via a single interface. It supports multiple logging channels and the output can be filtered using a mask. On top of this, multiple of backends can be used at the same time.
Index ¶
- Constants
- func Critical(format string, values ...interface{})
- func Debug(format string, values ...interface{})
- func Error(format string, values ...interface{})
- func Handle(err error, levels ...level)
- func Info(format string, values ...interface{})
- func Initialize(configurations ...*Configuration) error
- func Panic(v interface{})
- func Protocol(format string, values ...interface{})
- func Warning(format string, values ...interface{})
- type Configuration
Constants ¶
const ( BACKEND_CONSOLE backend = "console" BACKEND_FILE backend = "file" BACKEND_SYSLOG backend = "syslog" )
const ( LEVEL_CRITICAL level = 1 << iota LEVEL_ERROR LEVEL_WARNING LEVEL_INFO LEVEL_DEBUG LEVEL_PROTOCOL )
const ( MASK_ALL mask = mask(LEVEL_CRITICAL) | mask(LEVEL_ERROR) | mask(LEVEL_WARNING) | mask(LEVEL_INFO) | mask(LEVEL_DEBUG) | mask(LEVEL_PROTOCOL) MASK_DEBUG mask = mask(LEVEL_CRITICAL) | mask(LEVEL_ERROR) | mask(LEVEL_WARNING) | mask(LEVEL_INFO) | mask(LEVEL_DEBUG) MASK_DEFAULT mask = mask(LEVEL_CRITICAL) | mask(LEVEL_ERROR) | mask(LEVEL_WARNING) | mask(LEVEL_INFO) MASK_WARNING mask = mask(LEVEL_CRITICAL) | mask(LEVEL_ERROR) | mask(LEVEL_WARNING) )
Variables ¶
This section is empty.
Functions ¶
func Critical ¶
func Critical(format string, values ...interface{})
Critical uses format and values to generate a log message on the critical channel.
func Debug ¶
func Debug(format string, values ...interface{})
Debug uses format and values to generate a log message on the debug channel.
func Error ¶
func Error(format string, values ...interface{})
Error uses format and values to generate a log message on the error channel.
func Handle ¶
func Handle(err error, levels ...level)
Handle takes the given error and writes it to all channels that correspond to the given levels. If no level is given, the error will be published on the error channel.
func Info ¶
func Info(format string, values ...interface{})
Info uses format and values to generate a log message on the info channel.
func Initialize ¶
func Initialize(configurations ...*Configuration) error
Initialize sets up gol with a number of given configurations. Each configuration specified a single backend. By default, no backend is specified. In order to see any log message, Initialize has to be called.
For example
gol.Initialize(&gol.Configuration{Backend: "console", Mask: "all"})
will log all messages to the console.
Types ¶
type Configuration ¶
type Configuration struct { // common Backend string `json:"backend"` Mask string `json:"mask"` // console Color bool `json:"color"` // file Path string `json:"path"` Mode string `json:"mode"` // syslog Prefix string `json:"prefix"` }
Configuration holds all information that specify a single gol backend. While the common properties are needed for each backend, it holds also backend-specific properties.