logutil

package
v0.9.51 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PipelineName = "unknown"
View Source
var SlowQueryLogger = log.StandardLogger()

SlowQueryLogger is used to log slow query, InitLogger will modify it according to config file.

Functions

func GetLogLevelFromEnv

func GetLogLevelFromEnv() string

func InitLogger

func InitLogger(cfg *LogConfig) error

func MustInitLogger

func MustInitLogger(cfg *LogConfig)

func NewLogger

func NewLogger(cfg *LogConfig) (*log.Logger, error)

func SetLogLevelFromEnv

func SetLogLevelFromEnv()

Types

type FileLogConfig

type FileLogConfig struct {
	// Filename Log filename, leave empty to disable file log.
	Filename string `toml:"filename" json:"filename"`
	// LogRotate Is log rotate enabled. TODO.
	LogRotate bool `toml:"log-rotate" json:"log-rotate"`
	// MaxSize size for a single file, in MB.
	MaxSize int `toml:"max-size" json:"max-size"`
	// MaxDays log keep days, default is never deleting.
	MaxDays int `toml:"max-days" json:"max-days"`
	// MaxBackups Maximum number of old log files to retain.
	MaxBackups int `toml:"max-backups" json:"max-backups"`
	// Compress determines if the rotated log files should be compressed
	// using gzip. The default is not to perform compression.
	Compress bool `toml:"compress" json:"compress"`
}

FileLogConfig serializes file log related config in toml/json.

type LogConfig

type LogConfig struct {
	// Level Log level.
	Level string `toml:"level" json:"level"`
	// Format Log format. one of json, text, or console.
	Format string `toml:"format" json:"format"`
	// DisableTimestamp Disable automatic timestamps in output.
	DisableTimestamp bool `toml:"disable-timestamp" json:"disable-timestamp"`
	// File log config.
	File FileLogConfig `toml:"file" json:"file"`
	// SlowQueryFile filename, default to File log config on empty.
	SlowQueryFile string
}

LogConfig serializes log related config in toml/json.

type TestHook

type TestHook struct{}

func (*TestHook) Fire

func (hook *TestHook) Fire(entry *log.Entry) error

Fire implements logrus.Hook interface https://github.com/sirupsen/logrus/issues/63

func (*TestHook) Levels

func (hook *TestHook) Levels() []log.Level

Levels implements logrus.Hook interface.

Jump to

Keyboard shortcuts

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