common

package module
v0.0.0-...-87b3bb6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OptLog

type OptLog struct {

	//time format for screen log
	StdoutTimeFormat string
	//time format for log file
	LogFileTimeFormat string
	//path for all logs
	LogPath string
	//example prefix 'access' in access.log.20230105
	FileNamePrefix string
	//example suffix '%Y%m%d' for '20230105' in access.log.20230105
	FileNameSuffixTimeFormat string
	//error level log will be saved in seperated error.log for keeping more time if it's ture
	SetErrFileHook bool
	//keep log count
	KeepCount int
	//log level
	LogLevel logrus.Level
	//logFile
	//MapLogFile map[string]string
	//error log prefix error.log if SetErrFileHook is true
	ErrLogPrefix string
	//error log suffix "%Y%m" if SetErrFileHook is true
	ErrLogSuffix string
}

func InitOpt

func InitOpt() *OptLog

InitOpt

  • @msg init logrus params
  • @return: *OptLog

func (*OptLog) ConfigLogrus

func (opt *OptLog) ConfigLogrus() (*logrus.Logger, error)

ConfigLogrus

  • @msg to configure logrus with
  • 1. log format with color, timestamp
  • 2. log redirect by loglevel
  • 3. create file link for alive log
  • 4. set log keeping count
  • @receiver opt
  • @return: *logrus.Logger
  • @return: error

Jump to

Keyboard shortcuts

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