logger

package
v0.0.0-...-76f8149 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelDebug = iota
	LogLevelTrace
	LogLevelInfo
	LogLevelWarn
	LogLevelError
	LogLevelFatal
)
View Source
const (
	LogSplitTypeHour = iota
	LogSplitTypeSize
)

Variables

This section is empty.

Functions

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 GetLineInfo

func GetLineInfo() (fileName string, funcName string, lineNo int)

func Info

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

func InitLogger

func InitLogger(name string, config map[string]string) (err error)

file, "初始化一个文件日志实例" console, "初始化console日志实例"

func Trace

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

func Warn

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

Types

type ConsoleLogger

type ConsoleLogger struct {
	// contains filtered or unexported fields
}

func (*ConsoleLogger) Close

func (c *ConsoleLogger) Close()

func (*ConsoleLogger) Debug

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

func (*ConsoleLogger) Error

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

func (*ConsoleLogger) Fatal

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

func (*ConsoleLogger) Info

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

func (*ConsoleLogger) Init

func (c *ConsoleLogger) Init()

func (*ConsoleLogger) SetLevel

func (c *ConsoleLogger) SetLevel(level int)

func (*ConsoleLogger) Trace

func (c *ConsoleLogger) Trace(format string, args ...interface{})

func (*ConsoleLogger) Warn

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

type FileLogger

type FileLogger struct {
	LogDataChan chan *LogData
	// contains filtered or unexported fields
}

2018/3/26 0:01.383 DEBUG logDebug.go:29 this is a debug log 2006-01-02 15:04:05.999

func (*FileLogger) Close

func (f *FileLogger) Close()

func (*FileLogger) Debug

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

func (*FileLogger) Error

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

func (*FileLogger) Fatal

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

func (*FileLogger) Info

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

func (*FileLogger) Init

func (f *FileLogger) Init()

func (*FileLogger) SetLevel

func (f *FileLogger) SetLevel(level int)

func (*FileLogger) Trace

func (f *FileLogger) Trace(format string, args ...interface{})

func (*FileLogger) Warn

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

type LogData

type LogData struct {
	Message      string
	TimeStr      string
	LevelStr     string
	Filename     string
	FuncName     string
	LineNo       int
	WarnAndFatal bool // 区分警告log文件还是正常log文件
}

type LogInterface

type LogInterface interface {
	Init()
	SetLevel(level int)
	Debug(format string, args ...interface{})
	Trace(format string, args ...interface{})
	Info(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Error(format string, args ...interface{})
	Fatal(format string, args ...interface{})
	Close()
}

公用接口,所调用对象皆可使用实例

func NewConsoleLogger

func NewConsoleLogger(config map[string]string) (log LogInterface, err error)

func NewFileLogger

func NewFileLogger(config map[string]string) (log LogInterface, err error)

Jump to

Keyboard shortcuts

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