Documentation
¶
Overview ¶
Package logger implements a custom logger that prefixes log messages with the database name.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( LogLevels = []string{"debug", "info", "warning", "error", "fatal"} LogFormats = []string{"human", "logfmt", "json"} LogTimestamps = []string{"short", "disable", "full"} )
var DefaultConfig = Config{
Level: "info",
Format: "human",
Timestamp: "short",
}
DefaultConfig defines the default configuration
var FlagConfig = Config{}
FlagConfig captures flag values and defaults to zero values
Functions ¶
func RegisterFlags ¶
func RegisterFlags()
RegisterFlags registers several log flags. The default values are set to their zero value to allow detecting when the flag has been set. This allows the use of a config file for logging and overriding it with these flags.
func RegisterFlagsWith ¶
func RegisterFlagsWith(stringVar StringVarFlagFunc)
RegisterFlagsWith uses a specific function to register the flags with, allowing it to be used with different flag packages, like Cobra.
Types ¶
type Config ¶
type Config struct {
Level string `yaml:"level"` // One of LogLevels
Format string `yaml:"format"` // One of LogFormats
Timestamp string `yaml:"timestamp"` // One of LogTimestamps
}
Config configures logging
type NamespaceFormatter ¶
NamespaceFormatter is a logrus formatter that adds the 'db' field to a log prefix for nicer formatted text output.