Documentation ¶
Overview ¶
Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.
package logger is used for initializing logrus.
Index ¶
- Constants
- Variables
- func Debug(args ...interface{})
- func Error(args ...interface{})
- func FakeWriteLen(len1 int64)
- func Fatal(args ...interface{})
- func Info(args ...interface{})
- func Init(config *Config)
- func IsInitialized() bool
- func Panic(args ...interface{})
- func PrintColor(p []byte)
- func Sync()
- func Trace(args ...interface{})
- func Warn(args ...interface{})
- type Config
- type DefaultTextFormatter
- type Level
- type NoneTextFormatter
- type ShortTextFormatter
- type SimpleTextFormatter
Constants ¶
View Source
const ( HOUR int = iota DAY MONTH YEAR MB64 MB128 MB256 MB512 MB1024 SIZE_NO_LIMIT = 0 )
Variables ¶
View Source
var ( LogFileName string EnableCache = false )
Functions ¶
func IsInitialized ¶
func IsInitialized() bool
IsInitialized return if logger was initialized before.
Types ¶
type Config ¶
type Config struct { Formatter logrus.Formatter Level Level Write2File bool AlwaysWriteConsole bool // 是否总是将日志写入控制台 EnableCache bool RollingFileDir string RollingFileName string RollingPolicy []int }
Config is config for initializing logger.
type DefaultTextFormatter ¶
type DefaultTextFormatter struct { }
SimpleTextFormatter is default text formatter.
[I] 2019-12-12 12:12:12,221 [xxx.go] xxx
type Level ¶
type Level uint32
Level type
const ( // PanicLevel level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... PanicLevel Level = iota // FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the // logging level is set to Panic. FatalLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. ErrorLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // InfoLevel level. General operational entries about what's going on inside the // application. InfoLevel // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel // TraceLevel level. Designates finer-grained informational events than the Debug. TraceLevel )
These are the different logging levels. You can set the logging level to log on your instance of logger, obtained with `logrus.New()`.
func GetLogLevel ¶
func GetLogLevel() Level
type NoneTextFormatter ¶
type NoneTextFormatter struct { }
NoneTextFormatter is the simple version of log format.
xxx
type ShortTextFormatter ¶
type ShortTextFormatter struct { }
ShortTextFormatter is the simple version of log format.
[I] xxx
type SimpleTextFormatter ¶
type SimpleTextFormatter struct { }
SimpleTextFormatter is the simple version of log format.
[I] 12:12:12 xxx
Click to show internal directories.
Click to hide internal directories.