log

package
v0.0.0-...-75cae53 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultZapLogger = newZapLogger(false, os.Stdout)

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())

Functions

func AtLevel

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

AtLevel logs the message at a specific log level

func Configure

func Configure(config Config)

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/auth-service/auth-service.log and will be rolled when it reaches 20MB with a maximum of 1 backup.

func Debug

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

Debug Log a message at the debug level. Messages include any context that's accumulated on the logger, as well as any fields added at the log site.

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 Error

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

Error Log a message at the error level. Messages include any context that's accumulated on the logger, as well as any fields added at the log site.

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 Fatal

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

Fatal Log a message at the fatal level. Messages include any context that's accumulated on the logger, as well as any fields added at the log site.

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 Info

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

Info log a message at the info level. Messages include any context that's accumulated on the logger, as well as any fields added at the log site.

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 Panic

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

Panic Log a message at the Panic level. Messages include any context that's accumulated on the logger, as well as any fields added at the log site.

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 Sugar

func Sugar() *zap.SugaredLogger

Get the suger API for convenience

func Warn

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

Warn log a message at the warn level. Messages include any context that's accumulated on the logger, as well as any fields added at the log site.

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!

Types

type Config

type Config struct {
	// EncodeLogsAsJson makes the log framework log JSON
	EncodeLogsAsJson bool
	// FileLoggingEnabled makes the framework log to a file
	// the fields below can be skipped if this value is false!
	FileLoggingEnabled 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

Jump to

Keyboard shortcuts

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