Documentation ¶
Index ¶
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func DefaultRotateFileOutput(filename string) io.Writer
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func FileOutput(filename interface{}) io.Writer
- func GetLevel() level.Level
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func IsLevelEnabled(level level.Level) bool
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func Panicln(args ...interface{})
- func Print(args ...interface{})
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func ResetStandardLogger(options ...Option)
- func ResetStandardLoggerWithConfig(config Config)
- func RotateFileOutput(filename string, rotateTime time.Duration, expireTime time.Duration) io.Writer
- func StandardErrOutput() io.Writer
- func StandardOutput() io.Writer
- func Trace(args ...interface{})
- func Tracef(format string, args ...interface{})
- func Traceln(args ...interface{})
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warning(args ...interface{})
- func Warningf(format string, args ...interface{})
- func Warningln(args ...interface{})
- func Warnln(args ...interface{})
- type Config
- type Entry
- func (entry *Entry) Bytes() ([]byte, error)
- func (entry *Entry) Debug(args ...interface{})
- func (entry *Entry) Debugf(format string, args ...interface{})
- func (entry *Entry) Debugln(args ...interface{})
- func (entry *Entry) Error(args ...interface{})
- func (entry *Entry) Errorf(format string, args ...interface{})
- func (entry *Entry) Errorln(args ...interface{})
- func (entry *Entry) Fatal(args ...interface{})
- func (entry *Entry) Fatalf(format string, args ...interface{})
- func (entry *Entry) Fatalln(args ...interface{})
- func (entry Entry) HasCaller() bool
- func (entry *Entry) Info(args ...interface{})
- func (entry *Entry) Infof(format string, args ...interface{})
- func (entry *Entry) Infoln(args ...interface{})
- func (entry *Entry) Kernel() *logrus.Entry
- func (entry *Entry) Log(level level.Level, args ...interface{})
- func (entry *Entry) Logf(level level.Level, format string, args ...interface{})
- func (entry *Entry) Logln(level level.Level, args ...interface{})
- func (entry *Entry) Panic(args ...interface{})
- func (entry *Entry) Panicf(format string, args ...interface{})
- func (entry *Entry) Panicln(args ...interface{})
- func (entry *Entry) Print(args ...interface{})
- func (entry *Entry) Printf(format string, args ...interface{})
- func (entry *Entry) Println(args ...interface{})
- func (entry *Entry) String() (string, error)
- func (entry *Entry) Trace(args ...interface{})
- func (entry *Entry) Tracef(format string, args ...interface{})
- func (entry *Entry) Traceln(args ...interface{})
- func (entry *Entry) Warn(args ...interface{})
- func (entry *Entry) Warnf(format string, args ...interface{})
- func (entry *Entry) Warning(args ...interface{})
- func (entry *Entry) Warningf(format string, args ...interface{})
- func (entry *Entry) Warningln(args ...interface{})
- func (entry *Entry) Warnln(args ...interface{})
- func (entry *Entry) WithContext(ctx context.Context) *Entry
- func (entry *Entry) WithError(err error) *Entry
- func (entry *Entry) WithField(key string, value interface{}) *Entry
- func (entry *Entry) WithFields(fields field.Fields) *Entry
- type Logger
- func AddHook(hook hook.Hook) *Logger
- func DisableCaller() *Logger
- func New(options ...Option) *Logger
- func NewLoggerWithConfig(config Config) *Logger
- func RotateFileLogger(filename string, rotateTime time.Duration, expireTime time.Duration) *Logger
- func SetFormatter(formatter format.Formatter) *Logger
- func SetLevel(level level.Level) *Logger
- func SetOutput(out io.Writer) *Logger
- func StandardLogger() *Logger
- func (logger *Logger) AddHook(hook hook.Hook) *Logger
- func (logger *Logger) Debug(args ...interface{})
- func (logger *Logger) Debugf(format string, args ...interface{})
- func (logger *Logger) Debugln(args ...interface{})
- func (logger *Logger) DisableCaller() *Logger
- func (logger *Logger) Error(args ...interface{})
- func (logger *Logger) Errorf(format string, args ...interface{})
- func (logger *Logger) Errorln(args ...interface{})
- func (logger *Logger) Fatal(args ...interface{})
- func (logger *Logger) Fatalf(format string, args ...interface{})
- func (logger *Logger) Fatalln(args ...interface{})
- func (logger *Logger) GetLevel() level.Level
- func (logger *Logger) Info(args ...interface{})
- func (logger *Logger) Infof(format string, args ...interface{})
- func (logger *Logger) Infoln(args ...interface{})
- func (logger *Logger) IsLevelEnabled(level level.Level) bool
- func (logger *Logger) Kernel() *logrus.Logger
- func (logger *Logger) Log(level level.Level, args ...interface{})
- func (logger *Logger) Logf(level level.Level, format string, args ...interface{})
- func (logger *Logger) Logln(level level.Level, args ...interface{})
- func (logger *Logger) Panic(args ...interface{})
- func (logger *Logger) Panicf(format string, args ...interface{})
- func (logger *Logger) Panicln(args ...interface{})
- func (logger *Logger) Print(args ...interface{})
- func (logger *Logger) Printf(format string, args ...interface{})
- func (logger *Logger) Println(args ...interface{})
- func (logger *Logger) ReplaceHooks(hooks hook.LevelHooks) hook.LevelHooks
- func (logger *Logger) SetFormatter(formatter format.Formatter) *Logger
- func (logger *Logger) SetLevel(level level.Level) *Logger
- func (logger *Logger) SetNoLock() *Logger
- func (logger *Logger) SetOutput(output io.Writer) *Logger
- func (logger *Logger) Trace(args ...interface{})
- func (logger *Logger) Tracef(format string, args ...interface{})
- func (logger *Logger) Traceln(args ...interface{})
- func (logger *Logger) Warn(args ...interface{})
- func (logger *Logger) Warnf(format string, args ...interface{})
- func (logger *Logger) Warning(args ...interface{})
- func (logger *Logger) Warningf(format string, args ...interface{})
- func (logger *Logger) Warningln(args ...interface{})
- func (logger *Logger) Warnln(args ...interface{})
- func (logger *Logger) WithContext(ctx context.Context) *Entry
- func (logger *Logger) WithError(err error) *Entry
- func (logger *Logger) WithField(key string, value interface{}) *Entry
- func (logger *Logger) WithFields(fields field.Fields) *Entry
- type Option
- type RotateFileConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(args ...interface{})
Debug logs a message at level Debug on the standard logger.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs a message at level Debug on the standard logger.
func Debugln ¶
func Debugln(args ...interface{})
Debugln logs a message at level Debug on the standard logger.
func DefaultRotateFileOutput ¶
func Error ¶
func Error(args ...interface{})
Error logs a message at level Error on the standard logger.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs a message at level Error on the standard logger.
func Errorln ¶
func Errorln(args ...interface{})
Errorln logs a message at level Error on the standard logger.
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func Fatalln ¶
func Fatalln(args ...interface{})
Fatalln logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func FileOutput ¶
func Info ¶
func Info(args ...interface{})
Info logs a message at level Info on the standard logger.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs a message at level Info on the standard logger.
func Infoln ¶
func Infoln(args ...interface{})
Infoln logs a message at level Info on the standard logger.
func IsLevelEnabled ¶
IsLevelEnabled checks if the log level of the standard logger is greater than the level param
func Panic ¶
func Panic(args ...interface{})
Panic logs a message at level Panic on the standard logger.
func Panicf ¶
func Panicf(format string, args ...interface{})
Panicf logs a message at level Panic on the standard logger.
func Panicln ¶
func Panicln(args ...interface{})
Panicln logs a message at level Panic on the standard logger.
func Print ¶
func Print(args ...interface{})
Print logs a message at level Info on the standard logger.
func Printf ¶
func Printf(format string, args ...interface{})
Printf logs a message at level Info on the standard logger.
func Println ¶
func Println(args ...interface{})
Println logs a message at level Info on the standard logger.
func ResetStandardLogger ¶
func ResetStandardLogger(options ...Option)
func ResetStandardLoggerWithConfig ¶
func ResetStandardLoggerWithConfig(config Config)
func RotateFileOutput ¶
func StandardErrOutput ¶
func StandardOutput ¶
func Trace ¶
func Trace(args ...interface{})
Trace logs a message at level Trace on the standard logger.
func Tracef ¶
func Tracef(format string, args ...interface{})
Tracef logs a message at level Trace on the standard logger.
func Traceln ¶
func Traceln(args ...interface{})
Traceln logs a message at level Trace on the standard logger.
func Warn ¶
func Warn(args ...interface{})
Warn logs a message at level Warn on the standard logger.
func Warnf ¶
func Warnf(format string, args ...interface{})
Warnf logs a message at level Warn on the standard logger.
func Warning ¶
func Warning(args ...interface{})
Warning logs a message at level Warn on the standard logger.
func Warningf ¶
func Warningf(format string, args ...interface{})
Warningf logs a message at level Warn on the standard logger.
Types ¶
type Config ¶
type Config struct { // Level default INFO Level string `mapstructure:"level" json:"level"` // AppName Application name or web service name. If it is not empty, a field named "app" will be added to the log // 应用名称或Web服务名称,非空时会在日志中添加名为"app"的Field AppName string `mapstructure:"app_name" json:"app_name"` // Format The default format is JSON. Formatters.go provides two additional formats: text and bracket // 默认格式化方式为JSON,formatters.go额外提供了"text"和"bracket"两种格式 Format string `mapstructure:"format" json:"format"` // Timestamp Whether to display the timestamp, default true // 是否显示时间戳, 默认true Timestamp bool `mapstructure:"timestamp" json:"timestamp"` // File If this item is configured, it means that the output is a local file // 配置了File表示output为本地文件 File string `mapstructure:"file" json:"file"` // ErrFile If this item is configured, the log at error level will be input to a separate local file // 配置了ErrFile表示error级别的日志将输入到单独的本地文件 ErrFile string `mapstructure:"err_file" json:"err_file"` // RotateFile If this item is configured, which means that output is divided to the local file system by rotation // If File is configured at the same time, RotateFile will prevail // 配置了RotateFile表示output采用轮转分割到本地文件系统,若同时配置了File, 将以RotateFile为准 RotateFile RotateFileConfig `mapstructure:"rotate_file" json:"rotate_file"` }
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
func WithContext ¶
WithContext creates an entry from the standard logger and adds a context to it.
func WithError ¶
WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
func WithField ¶
WithField creates an entry from the standard logger and adds a field to it. If you want multiple fields, use `WithFields`.
Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.
func WithFields ¶
WithFields creates an entry from the standard logger and adds multiple fields to it. This is simply a helper for `WithField`, invoking it once for each field.
Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.
func (*Entry) String ¶
String Returns the string representation from the reader and ultimately the format.
func (*Entry) WithContext ¶
WithContext Add a context to the Entry.
func (*Entry) WithError ¶
WithError Add an error as single field (using the key defined in ErrorKey) to the Entry.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func DisableCaller ¶
func DisableCaller() *Logger
DisableCaller sets whether the standard logger will include the calling method as a field.
func NewLoggerWithConfig ¶
func RotateFileLogger ¶
func SetFormatter ¶
SetFormatter sets the standard logger format.
func StandardLogger ¶
func StandardLogger() *Logger
func (*Logger) DisableCaller ¶
DisableCaller set ReportCaller false
func (*Logger) IsLevelEnabled ¶
IsLevelEnabled checks if the log level of the logger is greater than the level param
func (*Logger) ReplaceHooks ¶
func (logger *Logger) ReplaceHooks(hooks hook.LevelHooks) hook.LevelHooks
ReplaceHooks replaces the logger hook and returns the old ones
func (*Logger) SetFormatter ¶
SetFormatter sets the logger format.
func (*Logger) SetNoLock ¶
SetNoLock When file is opened with appending mode, it's safe to write concurrently to a file (within 4k message on Linux). In these cases user can choose to disable the lock.
type Option ¶
type Option func(config *Config)
func WithAppName ¶
func WithErrFile ¶
func WithFormat ¶
func WithRotateFile ¶
func WithRotateFile(rotateFile RotateFileConfig) Option
func WithTimestamp ¶
type RotateFileConfig ¶
type RotateFileConfig struct { File string `mapstructure:"file" json:"file"` // RotateTime Log cutting interval // 日志切割时间间隔 RotateTime time.Duration `mapstructure:"rotate_time" json:"rotate_time"` // ExpireTime Maximum db time of log files // 日志文件最大保存时间 ExpireTime time.Duration `mapstructure:"expire_time" json:"expire_time"` }