logger

package
v0.2.18 Latest Latest
Warning

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

Go to latest
Published: May 11, 2019 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Index

Constants

View Source
const (
	ENV_LOG_LEVEL = "LOG_LEVEL"

	LOG_LEVEL_DEBUG = "debug"
	LOG_LEVEL_INFO  = "info"
	LOG_LEVEL_WARN  = "warn"
	LOG_LEVEL_ERROR = "error"

	DEFAULT_LOG_LEVEL = LOG_LEVEL_DEBUG
)

Variables

View Source
var AccessLog = NewLogger()
View Source
var Log = NewLogger()

Functions

func Access

func Access(fields map[string]interface{}, msg string)

func InitLogLevelFromEnv

func InitLogLevelFromEnv()

func SetLogLevel

func SetLogLevel()

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

export the *Logger object

func NewLogger

func NewLogger() *Logger

new a logger for logging

func (*Logger) AddHook

func (l *Logger) AddHook(hook logrus.Hook)

Add a hook to an instance of logger

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

The exported function for logger

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...interface{})

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

func (*Logger) GetLevel

func (l *Logger) GetLevel() logrus.Level

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

func (*Logger) Init

func (l *Logger) Init(config LoggerConfig) error

create a new lumberjack logger

func (*Logger) IsDebugEnabled

func (l *Logger) IsDebugEnabled() bool

func (*Logger) IsErrorEnabled

func (l *Logger) IsErrorEnabled() bool

func (*Logger) IsFatalEnabled

func (l *Logger) IsFatalEnabled() bool

func (*Logger) IsInfoEnabled

func (l *Logger) IsInfoEnabled() bool

func (*Logger) IsWarnEnabled

func (l *Logger) IsWarnEnabled() bool

func (*Logger) SetFormatter

func (l *Logger) SetFormatter(formatter logrus.Formatter)

sets the standard logger formatter.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level string)

set the log level for logging

func (*Logger) SetOutput

func (l *Logger) SetOutput(out io.Writer)

set the output for logging

func (*Logger) Warn

func (l *Logger) Warn(v ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(format string, v ...interface{})

func (*Logger) WithCaller

func (l *Logger) WithCaller(calllevel int) *logrus.Entry

func (*Logger) WithError

func (l *Logger) WithError(err error) *logrus.Entry

func (*Logger) WithFields

func (l *Logger) WithFields(fields logrus.Fields) *logrus.Entry

type LoggerConfig

type LoggerConfig struct {
	Level      string   `yaml:"Level"`
	FileName   string   `yaml:"FileName"`
	MaxBackups int      `yaml:"MaxBackups"`
	MaxSize    string   `yaml:"MaxSize"`
	MaxAge     int      `yaml:"MaxAge"`
	Hooks      []string // the name of plugin hook
}

the config information for logging

func (*LoggerConfig) GetOption

func (config *LoggerConfig) GetOption() (*Option, error)

type Option

type Option struct {
	Level      logrus.Level
	FileName   string // the file name for logging
	MaxSize    int    // the maximum size of a log file
	MaxBackups int    // the maximum number of backup files
	MaxAge     int    // the maximum days for log files
}

The Option for logger

Jump to

Keyboard shortcuts

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