log

package module
v0.0.0-...-c4af9d9 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: Apache-2.0 Imports: 3 Imported by: 3

README

log

log interface for go module

https://github.com/go-logr/logr

  • 1: 支持项目级别替换日志

  • 2: 支持模块级别替换日志

三方框架含有自有日志模块,通过SetLogger修改公式自有模块的日志实现,整合在一起。
优点:
  • 基于接口实现
  • 模块级别输出控制
缺点:
  • 基于 log4go 输出的文件和行号不准
快速使用
  • 参考 Test&&Example
Todo
  • 日志添加模块名字
  • [] 适配其他日志库
    • Kratos
    • log4go

Documentation

Index

Constants

View Source
const (
	DEBUG = iota + 1
	TRACE
	INFO
	WARNING
	ERROR
)

Variables

This section is empty.

Functions

func Debug

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

func Error

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

func Info

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

func SetLogger

func SetLogger(level Level, log Logger)

SetLogger 设置日志的具体输出 level 日志输出级别 log 日志的具体输出实现

func SetLoggerLevel

func SetLoggerLevel(level Level)

SetLoggerLevel 只修改默认的输出日志级别

func Trace

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

func Warn

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

Types

type KratosLog

type KratosLog struct {
}

func (*KratosLog) Debug

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

func (*KratosLog) Error

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

func (*KratosLog) Info

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

func (*KratosLog) Trace

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

func (*KratosLog) Warn

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

type Level

type Level int

type Log

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

func NewKratosLog

func NewKratosLog(level Level) *Log

NewKratosLog

func NewLog

func NewLog(log Logger, level Level) *Log

NewLog 实例化Log对象

func NewLog4go

func NewLog4go(level Level) *Log

NewLog4go 基于log4go的实现

func (*Log) Debug

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

Trace 输出TRACE级别日志,前提是level不高于TRACE才输出

func (*Log) Error

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

Error 输出ERROR级别日志,前提是level不高于ERROR才输出

func (*Log) Info

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

Info 输出INFO级别日志,前提是level不高于INFO才输出

func (*Log) SetTag

func (l *Log) SetTag(tag string)

func (*Log) Trace

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

Trace 输出TRACE级别日志,前提是level不高于TRACE才输出

func (*Log) Warn

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

Warn 输出WARN级别日志,前提是level不高于WARNING才输出

type Log4go

type Log4go struct {
}

func (*Log4go) Debug

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

func (*Log4go) Error

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

func (*Log4go) Info

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

func (*Log4go) Trace

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

func (*Log4go) Warn

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

type Logger

type Logger interface {
	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{})
}

模块使用

Directories

Path Synopsis
a

Jump to

Keyboard shortcuts

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