Documentation ¶
Overview ¶
Package tinylog provides an automated configuration of the global zerolog.Logger.
Index ¶
- func SetupLogger(opts ...Opt)
- type Config
- type ConsoleConfig
- type FileConfig
- type GelfConfig
- type LogFormat
- type Opt
- func ConsoleColors(colors bool) Opt
- func ConsoleEnabled(enabled bool) Opt
- func ConsoleFormat(format LogFormat) Opt
- func ConsoleOutput(output io.Writer) Opt
- func Field(name, value string) Opt
- func Fields(fields map[string]string) Opt
- func FileEnabled(enabled bool) Opt
- func FileFlags(flags int) Opt
- func FileFormat(format LogFormat) Opt
- func FileLocation(location string) Opt
- func FileMode(mode os.FileMode) Opt
- func GelfAddress(address string) Opt
- func GelfEnabled(enabled bool) Opt
- func Level(level string) Opt
- func TimeFormat(format string) 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. Default configuration can be overwritten by providing custom options as arguments.
Types ¶
type Config ¶
type Config struct { // Level is a log level to enable (default: "info"). Level string // TimeFormat specifies time format to use (default: "2006-01-02 15:04:05") TimeFormat string // 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 (default: true). Enabled bool // Output is a writer to write logs to (default: os.Stderr). Output io.Writer // Colors decides whether logging output should be colored or not (default: true for interactive terminals). Colors bool // Format is a format of this output. It could be either LogText or LogJSON (default: LogText). Format LogFormat }
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 (default: false). Enabled bool // Location is a path to the output file (default: "log.txt"). Location string // FileFlags specifies what flags to use when opening file (default: os.O_WRONLY | os.O_CREATE | os.O_APPEND). FileFlags int // FileMode specifies what mode to use when opening file (default: 0666). FileMode os.FileMode // Format is a format of this output. It could be either LogText or LogJSON (default: LogText). Format LogFormat }
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 (default: false). Enabled bool // Address is an address of the UDP socket in format HOST:PORT. 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 ConsoleOutput ¶
ConsoleOutput sets the writer to write logs to.
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.