Documentation
¶
Index ¶
- Constants
- func Debug(format string, args ...interface{})
- func DebugX(field string, format string, args ...interface{})
- func Error(format string, args ...interface{})
- func ErrorX(field string, format string, args ...interface{})
- func Fatal(format string, args ...interface{})
- func FatalX(field string, format string, args ...interface{})
- func FlushLog()
- func GetLogID(ctx context.Context) string
- func Info(format string, args ...interface{})
- func InfoX(field string, format string, args ...interface{})
- func InitLog(output string) (err error)
- func InitLogWithConfig(output string, cfg RotateConfig) (err error)
- func Warn(format string, args ...interface{})
- func WarnX(field string, format string, args ...interface{})
- type ConsoleHook
- type FileHook
- type Logger
- type RotateConfig
- type RotateHook
Constants ¶
View Source
const (
CtxKeyLogID = "U_LOGID"
)
Variables ¶
This section is empty.
Functions ¶
func InitLogWithConfig ¶ added in v0.2.0
func InitLogWithConfig(output string, cfg RotateConfig) (err error)
InitLogWithConfig initializes the logger with custom rotation config.
Types ¶
type ConsoleHook ¶
func (*ConsoleHook) Levels ¶
func (hook *ConsoleHook) Levels() []logrus.Level
type Logger ¶
func NewLoggerWithConfig ¶ added in v0.2.0
func NewLoggerWithConfig(filename string, rotateCfg RotateConfig) (*Logger, error)
NewLoggerWithConfig creates a logger with custom rotation config.
type RotateConfig ¶ added in v0.2.0
type RotateConfig struct {
MaxSize int64 // Max size in bytes before rotation.
MaxBackups int // Max number of old log files to keep
MaxAge int // Max days to keep old log files
}
RotateConfig holds configuration for log rotation.
type RotateHook ¶
type RotateHook struct {
Filename string
MaxSize int64
MaxBackups int
MaxAge int
LocalTime bool
// contains filtered or unexported fields
}
func NewRotateHook ¶
func NewRotateHook(filename string) *RotateHook
func NewRotateHookWithConfig ¶ added in v0.2.0
func NewRotateHookWithConfig(filename string, cfg RotateConfig) *RotateHook
NewRotateHookWithConfig creates a RotateHook with custom configuration. maxSize is in MB, will be converted to bytes internally.
func (*RotateHook) Levels ¶
func (hook *RotateHook) Levels() []logrus.Level
Click to show internal directories.
Click to hide internal directories.