zaplogger

package
v0.0.0-...-ce13bd1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtLevel

func AtLevel(level zapcore.Level, msg string, fields ...zapcore.Field)

AtLevel logs the message at a specific log level

func Debug

func Debug(msg string, keysAndValues ...interface{})

func Debugf

func Debugf(template string, args ...interface{})

func Debugs

func Debugs(args ...interface{})

func Debugt

func Debugt(msg string, fields ...zapcore.Field)

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

func Error

func Error(msg string, keysAndValues ...interface{})

func Errorf

func Errorf(template string, args ...interface{})

func Errors

func Errors(args ...interface{})

func Errort

func Errort(msg string, fields ...zapcore.Field)

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

func Fatal

func Fatal(msg string, keysAndValues ...interface{})

func Fatalf

func Fatalf(template string, args ...interface{})

func Fatals

func Fatals(args ...interface{})

func Fatalt

func Fatalt(msg string, fields ...zapcore.Field)

func Fatalw

func Fatalw(msg string, keysAndValues ...interface{})

func Info

func Info(msg string, keysAndValues ...interface{})

func Infof

func Infof(template string, args ...interface{})

func Infos

func Infos(args ...interface{})

func Infot

func Infot(msg string, fields ...zapcore.Field)

func Infow

func Infow(msg string, keysAndValues ...interface{})

func Panic

func Panic(msg string, keysAndValues ...interface{})

func Panicf

func Panicf(template string, args ...interface{})

func Panics

func Panics(args ...interface{})

func Panict

func Panict(msg string, fields ...zapcore.Field)

func Panicw

func Panicw(msg string, keysAndValues ...interface{})

func Warn

func Warn(msg string, keysAndValues ...interface{})

func Warnf

func Warnf(template string, args ...interface{})

func Warns

func Warns(args ...interface{})

func Warnt

func Warnt(msg string, fields ...zapcore.Field)

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Types

type Config

type Config struct {
	ConsoleEnabled bool
	ConsoleLevel   string
	ConsoleJson    bool

	FileEnabled bool
	FileLevel   string
	FileJson    bool

	// Directory to log to to when filelogging is enabled
	Directory string
	// Filename is the name of the logfile which will be placed inside the directory
	Filename string
	// MaxSize the max size in MB of the logfile before it's rolled
	MaxSize int
	// MaxBackups the max number of rolled files to keep
	MaxBackups int
	// MaxAge the max age in days to keep a logfile
	MaxAge int
}

Configuration for logging

type Logger

type Logger struct {
	Unsugared *zap.Logger
	*zap.SugaredLogger
}
var DefaultZapLogger *Logger

DefaultZapLogger is the default logger instance that should be used to log It's assigned a default value here for tests (which do not call log.Configure())

func Configure

func Configure(config Config) *Logger

Configure sets up the logging framework

In production, the container logs will be collected and file logging should be disabled. However, during development it's nicer to see logs as text and optionally write to a file when debugging problems in the containerized pipeline

The output log file will be located at /var/log/service-xyz/service-xyz.log and will be rolled according to configuration set.

func (*Logger) AtLevel

func (logger *Logger) AtLevel(level zapcore.Level, msg string, fields ...zapcore.Field) *Logger

func (*Logger) Debug

func (logger *Logger) Debug(msg string, keysAndValues ...interface{})

func (*Logger) Debugs

func (logger *Logger) Debugs(args ...interface{})

func (*Logger) Debugt

func (logger *Logger) Debugt(msg string, fields ...zapcore.Field)

Use zap.String(key, value), zap.Int(key, value) to log fields. These fields will be marshalled as JSON in the logfile and key value pairs in the console!

func (*Logger) Error

func (logger *Logger) Error(msg string, keysAndValues ...interface{})

func (*Logger) Errors

func (logger *Logger) Errors(args ...interface{})

func (*Logger) Errort

func (logger *Logger) Errort(msg string, fields ...zapcore.Field)

Use zap.String(key, value), zap.Int(key, value) to log fields. These fields will be marshalled as JSON in the logfile and key value pairs in the console!

func (*Logger) Fatal

func (logger *Logger) Fatal(msg string, keysAndValues ...interface{})

func (*Logger) Fatals

func (logger *Logger) Fatals(args ...interface{})

func (*Logger) Fatalt

func (logger *Logger) Fatalt(msg string, fields ...zapcore.Field)

Use zap.String(key, value), zap.Int(key, value) to log fields. These fields will be marshalled as JSON in the logfile and key value pairs in the console!

func (*Logger) Info

func (logger *Logger) Info(msg string, keysAndValues ...interface{})

func (*Logger) Infos

func (logger *Logger) Infos(args ...interface{})

func (*Logger) Infot

func (logger *Logger) Infot(msg string, fields ...zapcore.Field)

Use zap.String(key, value), zap.Int(key, value) to log fields. These fields will be marshalled as JSON in the logfile and key value pairs in the console!

func (*Logger) Panic

func (logger *Logger) Panic(msg string, keysAndValues ...interface{})

func (*Logger) Panics

func (logger *Logger) Panics(args ...interface{})

func (*Logger) Panict

func (logger *Logger) Panict(msg string, fields ...zapcore.Field)

Use zap.String(key, value), zap.Int(key, value) to log fields. These fields will be marshalled as JSON in the logfile and key value pairs in the console!

func (*Logger) Warn

func (logger *Logger) Warn(msg string, keysAndValues ...interface{})

func (*Logger) Warns

func (logger *Logger) Warns(args ...interface{})

func (*Logger) Warnt

func (logger *Logger) Warnt(msg string, fields ...zapcore.Field)

Use zap.String(key, value), zap.Int(key, value) to log fields. These fields will be marshalled as JSON in the logfile and key value pairs in the console!

type LoggerInterface

type LoggerInterface interface {
	Debugt(msg string, fields ...zapcore.Field)
	Debugf(template string, args ...interface{})
	Debugw(msg string, keysAndValues ...interface{})
	Debug(msg string, keysAndValues ...interface{})
	Debugs(args ...interface{})

	Infot(msg string, fields ...zapcore.Field)
	Infof(template string, args ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Info(msg string, keysAndValues ...interface{})
	Infos(args ...interface{})

	Warnt(msg string, fields ...zapcore.Field)
	Warnf(template string, args ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Warn(msg string, keysAndValues ...interface{})
	Warns(args ...interface{})

	Errort(msg string, fields ...zapcore.Field)
	Errorf(template string, args ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Error(msg string, keysAndValues ...interface{})
	Errors(args ...interface{})

	Panict(msg string, fields ...zapcore.Field)
	Panicf(template string, args ...interface{})
	Panicw(msg string, keysAndValues ...interface{})
	Panic(msg string, keysAndValues ...interface{})
	Panics(args ...interface{})

	Fatalt(msg string, fields ...zapcore.Field)
	Fatalf(template string, args ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})
	Fatal(msg string, keysAndValues ...interface{})
	Fatals(args ...interface{})

	AtLevel(level zapcore.Level, msg string, fields ...zapcore.Field) *Logger
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL