log

package
v0.22.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package log 提供基本的日志,分级,输出,轮转等功能 - 考虑使用公司的Log

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRotateFileHook

func NewRotateFileHook(config RotateFileConfig) (logrus.Hook, error)

Types

type Logger

type Logger struct {
	*logrus.Logger
}

func GetLogger

func GetLogger() *Logger

GetLogger 保证获取全局唯一的 Logger 单例 返回默认的日志服务

func (*Logger) SetFileOutPut

func (l *Logger) SetFileOutPut(logPath string, level string)

SetFileOutPut 根据指定的存储路径设置日志文件的存储路径,同时使用 lumberjack 实现日志文件的循环记录 如果循环记录的hook失败,直接panic退出

func (*Logger) SetLevel

func (l *Logger) SetLevel(level string)

setLevel 根据输入的级别字符串 (debug, info, ...) 设置日志级别,无法识别则导致 panic

type RotateFileConfig

type RotateFileConfig struct {
	Filename   string
	MaxSize    int
	MaxBackups int
	MaxAge     int
	Level      logrus.Level
	Formatter  logrus.Formatter
}

type RotateFileHook

type RotateFileHook struct {
	Config RotateFileConfig
	// contains filtered or unexported fields
}

func (*RotateFileHook) Fire

func (hook *RotateFileHook) Fire(entry *logrus.Entry) (err error)

func (*RotateFileHook) Levels

func (hook *RotateFileHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL