Documentation ¶
Index ¶
- func DisableQuote(logger *logrus.Logger)
- func DisableQuoteTemporarily(logger *logrus.Logger, callback func(logger *logrus.Logger))
- func DisposeLogger(logger *logrus.Logger) error
- func EnableQuote(logger *logrus.Logger)
- func MustSetUp(config *Config)
- func NewDefaultTextFormatter() *logrus.TextFormatter
- func NewFileAndStdoutLogger(filePath string, options ...LoggerOption) (*logrus.Logger, error)
- func NewFileLogger(filePath string, options ...LoggerOption) (*logrus.Logger, error)
- func NewLogger(options ...LoggerOption) *logrus.Logger
- func NewTextFormatter(timestampFormat string) *logrus.TextFormatter
- func PrintBasicDetails(logger *logrus.Logger)
- func SetUp(config *Config) error
- func StringToLevel(str string) (logrus.Level, error)
- type Config
- type LoggerOption
- func WithDisableQuote(disableQuote bool) LoggerOption
- func WithFormatter(formatter logrus.Formatter) LoggerOption
- func WithLevel(level logrus.Level) LoggerOption
- func WithMsgPrefix(msgPrefix string) LoggerOption
- func WithOutput(output io.Writer) LoggerOption
- func WithReportCaller(reportCaller bool) LoggerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableQuoteTemporarily ¶ added in v2.1.32
DisableQuoteTemporarily 临时禁用双引号(")
@param logger (1) 可以为nil(此时将采用logrus.StandardLogger())
(2) 只有当formatter为 *logrus.TextFormatter 类型,DisableQuote才会生效
func EnableQuote ¶
func NewDefaultTextFormatter ¶ added in v2.2.52
func NewDefaultTextFormatter() *logrus.TextFormatter
func NewFileAndStdoutLogger ¶ added in v2.2.51
func NewFileAndStdoutLogger(filePath string, options ...LoggerOption) (*logrus.Logger, error)
NewFileAndStdoutLogger 同时输出到 文件(not rotatable) 和 os.Stdout.
func NewFileLogger ¶
func NewFileLogger(filePath string, options ...LoggerOption) (*logrus.Logger, error)
NewFileLogger 输出到 文件(not rotatable).
func NewLogger ¶
func NewLogger(options ...LoggerOption) *logrus.Logger
NewLogger
PS: (1) 默认输出到 控制台(os.Stderr); (2) 如果希望 输出到文件 且 rotatable,可以使用 WithOutput(),详见下例.
@param options 可以什么都不配置(此时输出到控制台)
func NewTextFormatter ¶
func NewTextFormatter(timestampFormat string) *logrus.TextFormatter
NewTextFormatter
PS: 外部在调用此方法后,建议调用: Logger.SetReportCaller(true)!!!
@param timestampFormat 可以为""(将采用默认值)
e.g. 日志输出 time=2023-03-23 16:46:23.398+08:00 level=info msg=[CHIMERA, PROCESS] pid: [8579]. func=PrintBasicDetails(logrusKit/basicDetails.go:17) time=2023-03-23 16:46:23.398+08:00 level=info msg=[CHIMERA, OS] os: [darwin]. func=PrintBasicDetails(logrusKit/basicDetails.go:20) time=2023-03-23 16:46:23.398+08:00 level=info msg=[CHIMERA, OS] arch: [arm64]. func=PrintBasicDetails(logrusKit/basicDetails.go:21)
func PrintBasicDetails ¶
PrintBasicDetails 输出服务器的基本信息(以便于甩锅)
Types ¶
type LoggerOption ¶
type LoggerOption func(opts *loggerOptions)
func WithDisableQuote ¶ added in v2.2.52
func WithDisableQuote(disableQuote bool) LoggerOption
func WithFormatter ¶
func WithFormatter(formatter logrus.Formatter) LoggerOption
func WithLevel ¶
func WithLevel(level logrus.Level) LoggerOption
func WithMsgPrefix ¶ added in v2.2.46
func WithMsgPrefix(msgPrefix string) LoggerOption
func WithOutput ¶ added in v2.1.9
func WithOutput(output io.Writer) LoggerOption
func WithReportCaller ¶
func WithReportCaller(reportCaller bool) LoggerOption