Documentation ¶
Overview ¶
Package logx - an extension of logrus library. This package loads configurations from cfgx and create global logrus.Logger object. We can use logx like:
logx.Debug() logx.Info() ...
See Config for more information about configuration options.
Index ¶
- Constants
- func CallerPrettify(frame *runtime.Frame) (string, string)
- func Debug(args ...any)
- func Debugf(format string, args ...any)
- func Debugln(args ...any)
- func Error(args ...any)
- func Errorf(format string, args ...any)
- func Errorln(args ...any)
- func Fatal(args ...any)
- func FatalErr(err error) error
- func Fatalf(format string, args ...any)
- func Fatalln(args ...any)
- func Info(args ...any)
- func Infof(format string, args ...any)
- func Infoln(args ...any)
- func NewLogger(cfg *Config) *logrus.Logger
- func Panic(args ...any)
- func Panicf(format string, args ...any)
- func Panicln(args ...any)
- func Print(args ...any)
- func Printf(format string, args ...any)
- func Println(args ...any)
- func Warn(args ...any)
- func Warnf(format string, args ...any)
- func Warning(args ...any)
- func Warningf(format string, args ...any)
- func Warningln(args ...any)
- func Warnln(args ...any)
- type CallerHook
- type Config
Constants ¶
View Source
const ( KeyLevel = "logger.level" KeyWithCaller = "logger.with.caller" KeyFormatterType = "logger.formatter.type" KeyTimestampEnable = "logger.formatter.timestamp.enable" KeyTimestampFormat = "logger.formatter.timestamp.format" KeyPadLevelText = "logger.formatter.pad.level.text" KeyStdoutEnable = "logger.output.stdout.enable" KeyFileEnable = "logger.output.file.enable" KeyFileDir = "logger.output.file.dir" KeyFileName = "logger.output.file.name" KeyFileRotationEnable = "logger.output.file.rotation.enable" KeyFileRotationMaxSize = "logger.output.file.rotation.max.size" KeyFileRotationMaxBackups = "logger.output.file.rotation.max.backups" KeyFileRotationMaxAge = "logger.output.file.rotation.max.age" KeyFileRotationCompress = "logger.output.file.rotation.compress.enable" )
Variables ¶
This section is empty.
Functions ¶
func CallerPrettify ¶ added in v0.0.13
CallerPrettify - Prettify the caller.
Types ¶
type CallerHook ¶ added in v0.0.13
type CallerHook struct { }
CallerHook - A hook to regenerate the caller field.
func (*CallerHook) Levels ¶ added in v0.0.13
func (hook *CallerHook) Levels() []logrus.Level
type Config ¶
type Config struct { Level logrus.Level WithCaller bool // Text formatter configuration FormatterType string FormatterTimestampEnable bool FormatterTimestampFormat string FormatterPadLevelText bool // stdout output configuration. OutputStdoutEnable bool // file output configuration. OutputFileEnable bool OutputFileDir string OutputFileName string // file rotation configuration OutputFileRotationEnable bool OutputFileRotationMaxSize int OutputFileRotationMaxBackups int OutputFileRotationMaxAge int OutputFileRotationCompress bool }
var ( Cfg *Config DefCfg = &Config{ Level: logrus.InfoLevel, WithCaller: false, FormatterType: "text", FormatterTimestampEnable: true, FormatterTimestampFormat: time.DateTime + ".000", FormatterPadLevelText: true, OutputStdoutEnable: true, OutputFileEnable: false, OutputFileDir: "/var/log/sdp", OutputFileName: "sdp.log", OutputFileRotationEnable: false, OutputFileRotationMaxSize: 100, OutputFileRotationMaxBackups: 3, OutputFileRotationMaxAge: 30, OutputFileRotationCompress: false, } )
Click to show internal directories.
Click to hide internal directories.