logger

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 9 Imported by: 0

README

直接写入ElasticSearch 实验

    l := func NewEsLogger(level, user, password, index string, url []string)
    l.Debug("hello:%v", "nnn")

耗时38.425µs

直接打开一个协程不考虑是否写入成功至es

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EsLogger added in v1.3.0

type EsLogger struct {
	Client *elastic.Client

	Uri      []string
	Index    string
	UserName string
	Password string
	// contains filtered or unexported fields
}

func NewEsLogger added in v1.3.0

func NewEsLogger(level, user, password, index string, url []string) *EsLogger

func (*EsLogger) Debug added in v1.3.0

func (l *EsLogger) Debug(msg string, a ...interface{})

Debug 方法

func (*EsLogger) Error added in v1.3.0

func (l *EsLogger) Error(msg string, a ...interface{})

Error 方法

func (*EsLogger) Fatal added in v1.3.0

func (l *EsLogger) Fatal(msg string, a ...interface{})

Fatal 方法

func (*EsLogger) Info added in v1.3.0

func (l *EsLogger) Info(msg string, a ...interface{})

Info 方法

func (*EsLogger) Init added in v1.3.0

func (e *EsLogger) Init()

func (*EsLogger) Waring added in v1.3.0

func (l *EsLogger) Waring(msg string, a ...interface{})

Waring 方法

type FileLogger

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

func NewFileLogger

func NewFileLogger(level, fp, fn string, maxSize int64) *FileLogger

构造函数 文件输入

func (*FileLogger) Close

func (f *FileLogger) Close(file *os.File)

关闭文件

func (*FileLogger) Debug

func (l *FileLogger) Debug(msg string, a ...interface{})

Debug 方法

func (*FileLogger) Error

func (l *FileLogger) Error(msg string, a ...interface{})

Error 方法

func (FileLogger) Fatal

func (l FileLogger) Fatal(msg string, a ...interface{})

Fatal 方法

func (*FileLogger) Info

func (l *FileLogger) Info(msg string, a ...interface{})

Info 方法

func (*FileLogger) Waring

func (l *FileLogger) Waring(msg string, a ...interface{})

Waring 方法

type Info added in v1.3.0

type Info struct {
	FuncName string                `json:"funcName"`
	FileName string                `json:"fileName"`
	Line     int64                 `json:"line"`
	Level    string                `json:"level"`
	Message  string                `json:"message"`            // 微博内容
	Created  time.Time             `json:"created,omitempty"`  // 创建时间
	Location string                `json:"location,omitempty"` //位置
	Suggest  *elastic.SuggestField `json:"suggest_field,omitempty"`
}

type Level

type Level uint16
const (
	UNKNOW Level = iota
	DEBUG
	INFO
	WARING
	ERROR
	FATAL
)

func ParseLevel

func ParseLevel(s string) (Level, error)

解析日志级别

type Log

type Log interface {
	Debug(msg string, a ...interface{})
	Info(msg string, a ...interface{})
	Waring(msg string, a ...interface{})
	Error(msg string, a ...interface{})
	Fatal(msg string, a ...interface{})
}

type Logger

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

Logger 日志结构体

func NewLog

func NewLog(levelStr string) Logger

NewLog 构造函数

func (Logger) Debug

func (l Logger) Debug(msg string, a ...interface{})

Debug 方法

func (Logger) Error

func (l Logger) Error(msg string, a ...interface{})

Error 方法

func (Logger) Fatal

func (l Logger) Fatal(msg string, a ...interface{})

Fatal 方法

func (Logger) Info

func (l Logger) Info(msg string, a ...interface{})

Info 方法

func (Logger) Waring

func (l Logger) Waring(msg string, a ...interface{})

Waring 方法

Jump to

Keyboard shortcuts

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