Documentation ¶
Index ¶
Constants ¶
View Source
const ( //Debug has verbose message Debug = "debug" //Info is default log level Info = "info" //Warn is for logging messages about possible issues Warn = "warn" //Error is for logging errors Error = "error" //Fatal is for logging fatal messages. The system shutdown after logging the message. Fatal = "fatal" )
View Source
const DefaultLogger = InstanceZapLogger
expose the default logger in a variable. TODO add a config to change it at runtime? overkill
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { // stdOut logging EnableConsole bool ConsoleJSONFormat bool ConsoleLevel LoggerLevel Color bool // file logging EnableFile bool FileJSONFormat bool FileLevel LoggerLevel FileLocation string }
Configuration stores the config for the logger For some loggers there can only be one level across writers, for such the level of Console is picked by default
func NewConfig ¶
func NewConfig(conf *viper.Viper) *Configuration
Creates a new logger config based on viper config settings.
type Fields ¶
type Fields map[string]interface{}
Fields Type to pass when we want to call WithFields for structured logging
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) WithFields(keyValues Fields) Logger }
Logger is our contract for the logger
var Log Logger
A global variable so that log functions can be directly accessed
func NewLogger ¶
func NewLogger(config *Configuration, loggerInstance LoggerInstance) (Logger, error)
NewLogger returns an instance of logger
type LoggerInstance ¶
type LoggerInstance int
const ( InstanceZapLogger LoggerInstance = iota InstanceLogrusLogger )
type LoggerLevel ¶
type LoggerLevel string
Define a type for parameters in functions
func NormalizeLogLevel ¶
func NormalizeLogLevel(logLevel string) LoggerLevel
Click to show internal directories.
Click to hide internal directories.