Documentation ¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Debugw(msg string, kv ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Errorw(msg string, kv ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Fatalw(msg string, kv ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func Infow(msg 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(msg 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(msg string, kv ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(template string, args ...interface{})
- func (l *Logger) Errorw(msg string, kv ...interface{})
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(template string, args ...interface{})
- func (l *Logger) Fatalw(msg string, kv ...interface{})
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(template string, args ...interface{})
- func (l *Logger) Infow(msg string, kv ...interface{})
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(template string, args ...interface{})
- func (l *Logger) Warnw(msg 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(msg 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(msg 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(msg 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 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"). // In development mode enables development mode (which makes DPanicLevel logs panic), uses a console encoder, writes to standard error, and disables sampling. Stacktraces are automatically included on logs of WarnLevel and above. // Check [here](https://pkg.go.dev/go.uber.org/zap@v1.24.0#NewDevelopmentConfig) 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.
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.