Documentation
¶
Overview ¶
Provides an automated configuration of the global zerolog.Logger
Index ¶
- func SetupLogger(opts ...Opt)
- type Config
- type ConsoleConfig
- type FileConfig
- type GelfConfig
- type Opt
- func ConsoleColors(colors bool) Opt
- func ConsoleEnabled(enabled bool) Opt
- func ConsoleFormat(format string) Opt
- func Field(name, value string) Opt
- func Fields(fields map[string]string) Opt
- func FileEnabled(enabled bool) Opt
- func FileFormat(format string) Opt
- func FileLocation(location string) Opt
- func GelfAddress(address string) Opt
- func GelfEnabled(enabled bool) Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupLogger ¶
func SetupLogger(opts ...Opt)
SetupLogger configures the global instance of zerolog.Logger using global configuration from config.Config. Configuration can be further overwritten by providing custom options as arguments. SetupLogger uses "log.*" configuration keys. Each of the available log outputs (console, file, gelf) can be configured separately by providing "log.console.*", "log.file.*" and "log.gelf.*" keys. By default, only the "console" output is enabled, and is using "text" format, console colors are enabled if the global info.Profile is set to info.ProfileDebug. Global logging level can be configured with "log.level" config key, by default it set to "info".
Types ¶
type Config ¶
type Config struct { // Console is an instance of ConsoleConfig.. Console ConsoleConfig // File is an instance of FileConfig. File FileConfig // Gelf is an instance of GelfConfig. Gelf GelfConfig // contains filtered or unexported fields }
Config represents a configuration of the global logger.
type ConsoleConfig ¶
type ConsoleConfig struct { // Enabled decides whether this output should be enabled or not. Enabled bool // Colors decides whether logging output should be colored or not. Colors bool // Format is a format of this output. It could be either "text" or "json". Format string }
ConsoleConfig represents a configuration for console output. This output is emitted to os.Stderr.
type FileConfig ¶
type FileConfig struct { // Enabled decides whether this output should be enabled or not. Enabled bool // Location is a path to the output file. Location string // Format is a format of this output. It could be either "text" or "json". Format string }
FileConfig represents a configuration for file output. This output is emitted to a file.
type GelfConfig ¶
type GelfConfig struct { // Enabled decides whether this output should be enabled or not. Enabled bool // Address is an address of the UDP socket in format HOST:PORT, for example: localhost:2000. Address string }
GelfConfig represents a configuration for gelf output. This output is emitted to a UDP socket.
type Opt ¶
type Opt func(*Config)
Opt is an option to be specified to SetupLogger.
func ConsoleColors ¶
ConsoleColors sets Colors parameter of the console output.
func ConsoleEnabled ¶
ConsoleEnabled sets Enabled parameter of the console output.
func ConsoleFormat ¶
ConsoleFormat sets Format parameter of the console output.
func FileEnabled ¶
FileEnabled sets Enabled parameter of the file output.
func FileFormat ¶
FileFormat sets Format parameter of the file output.
func FileLocation ¶
FileLocation sets Location parameter of the file output.
func GelfAddress ¶
GelfAddress sets Address parameter of the gelf output.
func GelfEnabled ¶
GelfEnabled sets Enabled parameter of the gelf output.