logger

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitFileLogger

func InitFileLogger(logger *log.Logger, logConf *LogConfig) error

* InitFileLogger - initialize file logger * PARAMS: * - logger: *log.Logger * - logConf: config of log * RETURNS: * nil, if succeed * error, if fail

func InitStandardFileLogger

func InitStandardFileLogger(logConf *LogConfig) error

* InitStandardFileLogger - initialize standard logger for file record * PARAMS: * - logConf: config of log * RETURNS: * nil, if succeed * error, if fail

func LogFlags

func LogFlags(logConf *LogConfig) []cli.Flag

func Logger

func Logger() *log.Entry

func LoggerForJob

func LoggerForJob(jobID string) *log.Entry

func LoggerForRequest

func LoggerForRequest(ctx *RequestContext) *log.Entry

func LoggerForRun

func LoggerForRun(runID string) *log.Entry

Types

type Formatter

type Formatter struct {
	// Timestamp format
	TimestampFormat string
	// Available standard keys: time, msg, lvl
	// Also can include custom fields but limited to strings.
	// All of fields need to be wrapped inside %% i.e %time% %msg%
	LogFormat string
}

Formatter implements logrus.Formatter interface.

func (*Formatter) Format

func (f *Formatter) Format(entry *log.Entry) ([]byte, error)

Format building logger message.

type LogConfig

type LogConfig struct {
	Dir             string `yaml:"dir"`
	FilePrefix      string `yaml:"filePrefix"`
	Level           string `yaml:"level"`
	MaxKeepDays     int    `yaml:"maxKeepDays"`
	MaxFileNum      int    `yaml:"maxFileNum"`
	MaxFileSizeInMB int    `yaml:"maxFileSizeInMB"`
	IsCompress      bool   `yaml:"isCompress"`
	Formatter       string `yaml:"formatter"`
}

type RequestContext

type RequestContext struct {
	RequestID    string
	UserID       string
	UserName     string
	GrpcCode     codes.Code
	ErrorCode    string
	ErrorMessage string
}

func (*RequestContext) Logging

func (ctx *RequestContext) Logging() *log.Entry

Jump to

Keyboard shortcuts

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