log

package
v0.0.0-...-e1ef45a Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Context string `default:"sw-api"`
	// Enable console logging
	ConsoleLoggingEnabled bool `default:"true"`
	// EncodeLogsAsJson makes the log framework log JSON
	EncodeLogsAsJson bool `default:"true"`
	// FileLoggingEnabled makes the framework log to a file
	// the fields below can be skipped if this value is false!
	FileLoggingEnabled bool `default:"true"`
	// Directory to log to to when filelogging is enabled
	Directory string `default:"/var/log/sw-api-server"`
	// Filename is the name of the logfile which will be placed inside the directory
	Filename string `default:"sw-api-server"`
	// MaxSize the max size in MB of the logfile before it's rolled
	MaxSize int `default:"10"`
	// MaxBackups the max number of rolled files to keep
	MaxBackups int `default:"10"`
	// MaxAge the max age in days to keep a logfile
	MaxAge int `default:"2"`
}

Config - Configuration for logging

type Logger

type Logger struct {
	*zerolog.Logger
	// contains filtered or unexported fields
}

func New

func New(config *Config) *Logger

New 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) C

func (l *Logger) C(tags ...interface{}) *Logger

func (*Logger) D

func (l *Logger) D(message string, tags ...interface{})

func (*Logger) E

func (l *Logger) E(message string, tags ...interface{})

func (*Logger) F

func (l *Logger) F(message string, tags ...interface{})

func (*Logger) I

func (l *Logger) I(message string, tags ...interface{})

func (*Logger) L

func (l *Logger) L(message string, tags ...interface{})

func (*Logger) W

func (l *Logger) W(message string, tags ...interface{})

Jump to

Keyboard shortcuts

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