logger

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

logger

  • 支持配置日志级别
  • 支持自定义拆分方式
    • 默认按大小拆分 1G
    • 还支持按时间拆分

使用方法

go get -u github.com/ropon/logger

使用方法

func main() {
    logger.InitLog()
    logger.Info("这是一条信息日志")
}

Documentation

Index

Constants

View Source
const (
	Reset       = "\033[0m"
	Red         = "\033[31m"
	Green       = "\033[32m"
	Yellow      = "\033[33m"
	Blue        = "\033[34m"
	Magenta     = "\033[35m"
	Cyan        = "\033[36m"
	White       = "\033[37m"
	BlueBold    = "\033[34;1m"
	MagentaBold = "\033[35;1m"
	RedBold     = "\033[31;1m"
	YellowBold  = "\033[33;1m"
)

Variables

This section is empty.

Functions

func Close

func Close()

func ColorForMethod

func ColorForMethod(method string) string

func ColorForStatus

func ColorForStatus(code int) string

func Debug

func Debug(format string, args ...interface{})

func Error

func Error(format string, args ...interface{})

func Fatal

func Fatal(format string, args ...interface{})

func Info

func Info(format string, args ...interface{})

func InitLog

func InitLog(logCfgS ...*LogCfg) (err error)

func NewFileLogger

func NewFileLogger(logCfg *LogCfg) (*fileLogger, error)

NewFileLogger 日志结构体 构造函数

func Panic

func Panic(format string, args ...interface{})

func Warn

func Warn(format string, args ...interface{})

Types

type ConsoleLogger

type ConsoleLogger struct {
	Level string
}

ConsoleLogger 终端结构体

func NewConsoleLogger

func NewConsoleLogger(Level string) *ConsoleLogger

NewConsoleLogger 构造终端结构体函数

func (*ConsoleLogger) Close

func (f *ConsoleLogger) Close()

Close 终端不需要关闭

func (*ConsoleLogger) Debug

func (f *ConsoleLogger) Debug(format string, args ...interface{})

Debug 调试日志

func (*ConsoleLogger) Error

func (f *ConsoleLogger) Error(format string, args ...interface{})

Error 错误日志

func (*ConsoleLogger) Fatal

func (f *ConsoleLogger) Fatal(format string, args ...interface{})

Fatal 严重错误日志

func (*ConsoleLogger) Info

func (f *ConsoleLogger) Info(format string, args ...interface{})

Info 一般日志

func (*ConsoleLogger) Print

func (f *ConsoleLogger) Print(args ...interface{})

func (*ConsoleLogger) Warn

func (f *ConsoleLogger) Warn(format string, args ...interface{})

Warn 警告日志

type LogCfg

type LogCfg struct {
	Level     string
	FilePath  string
	FileName  string
	MaxSize   int64
	SplitFlag bool
	TimeDr    float64
}

type Logger

type Logger interface {
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Error(format string, args ...interface{})
	Fatal(format string, args ...interface{})
	Panic(format string, args ...interface{})
	Print(args ...interface{})
	Close()
}

Logger 是一个日志接口

var Log Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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