Documentation
¶
Overview ¶
Package tinylog provides an automated configuration of the global zerolog.Logger.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupLogger ¶
func SetupLogger(config ...*Config)
SetupLogger configures the global instance of zerolog.Logger.
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
// Fields is a set of fields to include in each log line.
Fields map[string]string
}
Config represents a configuration of the global logger.
type ConsoleConfig ¶
type ConsoleConfig struct {
// Disabled decides whether this output should be disabled or not (default: false).
Disabled bool
// Output is a writer to write logs to (default: os.Stderr).
Output io.Writer
// ColorsDisabled decides whether logging output should be colored or not.
// (default: false for interactive terminals, true for others).
ColorsDisabled 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.
Click to show internal directories.
Click to hide internal directories.