Documentation ¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Debugw(template string, kv ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Errorw(template string, kv ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Fatalw(template string, kv ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func Infow(template string, kv ...interface{})
- func Init(cfg Config)
- func NewLogger(cfg Config) (*zap.SugaredLogger, *zap.AtomicLevel, error)
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- func Warnw(template string, kv ...interface{})
- type Config
- type LogEnvironment
- type Logger
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(template string, args ...interface{})
- func (l *Logger) Debugw(template string, kv ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(template string, args ...interface{})
- func (l *Logger) Errorw(template string, kv ...interface{})
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(template string, args ...interface{})
- func (l *Logger) Fatalw(template string, kv ...interface{})
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(template string, args ...interface{})
- func (l *Logger) Infow(template string, kv ...interface{})
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(template string, args ...interface{})
- func (l *Logger) Warnw(template string, kv ...interface{})
- func (l *Logger) WithFields(keyValuePairs ...interface{}) *Logger
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 Debugw ¶
func Debugw(template string, kv ...interface{})
Debugw calls log.Debugw 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 Errorw ¶
func Errorw(template string, kv ...interface{})
Errorw calls log.Errorw on the root Logger.
func Fatalf ¶
func Fatalf(template string, args ...interface{})
Fatalf calls log.Fatalf on the root Logger.
func Fatalw ¶
func Fatalw(template string, kv ...interface{})
Fatalw calls log.Fatalw on the root Logger.
func Infof ¶
func Infof(template string, args ...interface{})
Infof calls log.Infof on the root Logger.
func Infow ¶
func Infow(template string, kv ...interface{})
Infow calls log.Infow on the root Logger.
func Init ¶
func Init(cfg Config)
Init the logger with defined level. outputs 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 NewLogger ¶
func NewLogger(cfg Config) (*zap.SugaredLogger, *zap.AtomicLevel, error)
NewLogger creates the logger with defined level. outputs 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"}
Types ¶
type Config ¶
type Config struct { // Environment defining the log format ("production" or "development"). Environment LogEnvironment `mapstructure:"Environment"` // Level of log, e.g. INFO, WARN, ... Level string `mapstructure:"Level"` // Outputs Outputs []string `mapstructure:"Outputs"` }
Config for log
type LogEnvironment ¶
type LogEnvironment string
LogEnvironment represents the possible log environments.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a wrapper providing logging facilities.
func WithFields ¶
func WithFields(keyValuePairs ...interface{}) *Logger
WithFields returns a new Logger (derived from the root one) with additional fields as per keyValuePairs. The root Logger instance is not affected.
func (*Logger) WithFields ¶
WithFields returns a new Logger with additional fields as per keyValuePairs. The original Logger instance is not affected.