logger

package module
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(c *LogConfig)

Types

type LogConfig

type LogConfig struct {
	// Level is the log level to log at
	Level string

	// ConsoleEnabled enable console logging
	ConsoleEnabled bool

	// ConsoleJson is a flag to output log messages in json format
	ConsoleJson bool

	// FileEnabled enable file logging
	FileEnabled bool

	// FileJson is a flag to output log messages in json format
	FileJson bool

	// Directory to log 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
}

func LoadEnvForLogger

func LoadEnvForLogger() *LogConfig

func (*LogConfig) ConsoleEncoderConfig

func (c *LogConfig) ConsoleEncoderConfig() zapcore.EncoderConfig

func (*LogConfig) FileEncoderConfig

func (c *LogConfig) FileEncoderConfig() zapcore.EncoderConfig

func (*LogConfig) InitLumberjackLogger

func (c *LogConfig) InitLumberjackLogger() lumberjack.Logger

InitLumberjackLogger initialize lumberjack logger. Automatically create log directory if not exists. This will roll the log file when it reaches the max size.

Jump to

Keyboard shortcuts

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