Documentation ¶
Index ¶
- Constants
- func Debugf(template string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func InitLogger(cfg Config) error
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- func WithFields(keyValuePairs ...interface{}) *zap.SugaredLogger
- type Config
- type LogEnvironment
Constants ¶
const ( // EnvironmentProduction production log environment. EnvironmentProduction = LogEnvironment("production") // EnvironmentDevelopment development log environment. EnvironmentDevelopment = LogEnvironment("development") )
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(template string, args ...interface{})
Debugf calls log.Debugf on the root Logger.
func Errorf ¶
func Errorf(template string, args ...interface{})
Errorf calls log.Errorf on the root logger and stores the error message into the ErrorFile.
func Fatalf ¶
func Fatalf(template string, args ...interface{})
Fatalf calls log.Fatalf on the root Logger.
func Infof ¶
func Infof(template string, args ...interface{})
Infof calls log.Infof on the root Logger.
func InitLogger ¶
InitLogger creates the logger with defined level. Outputs parameter defines the outputs where the logs will be sent. By default, outputs contains "stdout", which prints the logs at the output of the process. To add a log file as output, the path should be added at the outputs array. To avoid printing the logs but storing them on a file, can use []string{"pathtofile.log"}
func Warnf ¶
func Warnf(template string, args ...interface{})
Warnf calls log.Warnf on the root Logger.
func WithFields ¶
func WithFields(keyValuePairs ...interface{}) *zap.SugaredLogger
WithFields returns a new Logger (derived from the root one) with additional fields as per keyValuePairs. The root Logger instance is not affected.
Types ¶
type Config ¶
type Config struct { // Environment defining the log format ("production" or "development"). Environment LogEnvironment `mapstructure:"Environment" jsonschema:"enum=production,enum=development"` // Level of log. As lower value more logs are going to be generated Level string `mapstructure:"Level" jsonschema:"enum=debug,enum=info,enum=warn,enum=error,enum=dpanic,enum=panic,enum=fatal"` // Outputs Outputs []string `mapstructure:"Outputs"` }
Config for log
type LogEnvironment ¶
type LogEnvironment string
LogEnvironment represents the possible log environments.