logx

package
v1.2.30 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 27 Imported by: 8

Documentation

Index

Constants

View Source
const (
	DebugLevel  = zapcore.DebugLevel
	InfoLevel   = zapcore.InfoLevel
	WarnLevel   = zapcore.WarnLevel
	ErrorLevel  = zapcore.ErrorLevel
	DPanicLevel = zapcore.DPanicLevel
	PanicLevel  = zapcore.PanicLevel
	FatalLevel  = zapcore.FatalLevel
)

Variables

This section is empty.

Functions

func DPanic

func DPanic(args ...interface{})

func Debug

func Debug(args ...interface{})

func Error

func Error(args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Format

func Format(value ...interface{}) string

func GetWriter

func GetWriter() io.Writer

func GinLogger

func GinLogger() gin.HandlerFunc

GinLogger 接收gin框架默认的日志

func GinRecovery

func GinRecovery(stack bool) gin.HandlerFunc

GinRecovery recover掉项目可能出现的panic,并使用zap记录相关日志

func Info

func Info(args ...interface{})

func InitLogger

func InitLogger(filename string, level zapcore.Level)

InitLogger level: debug,info,warn,error,panic,fatal

func InitLoggerWithOutFile

func InitLoggerWithOutFile(level zapcore.Level)

func KratosServer

func KratosServer(logger klog.Logger) middleware.Middleware

KratosServer is an server logging middleware.

func NewKratosLogger

func NewKratosLogger(logger *Logger) klog.Logger

NewKratosLogger returns a new kratos logger

func Panic

func Panic(args ...interface{})

func PushToMqtt

func PushToMqtt(mqtt *emqx.MQTT, topic string) func(Message) error

PushToMqtt 推送至Mq

func Recovery

func Recovery()

Recovery recover掉项目可能出现的panic,并使用zap记录相关日志

func Warn

func Warn(args ...interface{})

Types

type Collector

type Collector struct {
	// 日志收集器名称
	Name string
	// 日志队列
	LogChan chan string
	// 例如:http、kafka、nacos 等
	Push Push
}

Collector 日志收集器

type CommonLogger

type CommonLogger struct {
	Logger
}

CommonLogger fmgo内部通用日志接口

func NewCommonLogger

func NewCommonLogger(logger *Logger) CommonLogger

NewCommonLogger 创建一个通用日志对象

func (CommonLogger) DPanic

func (l CommonLogger) DPanic(args ...interface{})

func (CommonLogger) Debug

func (l CommonLogger) Debug(args ...interface{})

func (CommonLogger) Error

func (l CommonLogger) Error(args ...interface{})

func (CommonLogger) Fatal

func (l CommonLogger) Fatal(args ...interface{})

func (CommonLogger) Info

func (l CommonLogger) Info(args ...interface{})

func (CommonLogger) Panic

func (l CommonLogger) Panic(args ...interface{})

func (CommonLogger) Warn

func (l CommonLogger) Warn(args ...interface{})

type GormLogger

type GormLogger struct {
	glogger.Interface
	glogger.Config

	*Logger
	// contains filtered or unexported fields
}

func NewGormLogger

func NewGormLogger(config glogger.Config) *GormLogger

NewGormLogger returns a new GormLogger instance.

func (*GormLogger) Error

func (l *GormLogger) Error(ctx context.Context, msg string, data ...interface{})

Error print error messages

func (*GormLogger) Info

func (l *GormLogger) Info(ctx context.Context, msg string, data ...interface{})

Info print info

func (*GormLogger) LogMode

func (l *GormLogger) LogMode(level glogger.LogLevel) glogger.Interface

LogMode log mode

func (*GormLogger) Trace

func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace print sql message

func (*GormLogger) Warn

func (l *GormLogger) Warn(ctx context.Context, msg string, data ...interface{})

Warn print warn messages

type KratosLogger

type KratosLogger struct {
	*Logger
}

func (KratosLogger) Log

func (l KratosLogger) Log(level klog.Level, msg ...interface{}) error

type Level

type Level zapcore.Level

type Logger

type Logger struct {
	*zap.Logger
	Collector *Collector
}

func GetLogger

func GetLogger() *Logger

func (*Logger) DPanic

func (l *Logger) DPanic(msg string)

func (*Logger) Debug

func (l *Logger) Debug(msg string)

func (*Logger) Error

func (l *Logger) Error(msg string)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

func (*Logger) Info

func (l *Logger) Info(msg string)

func (*Logger) NewCollector

func (l *Logger) NewCollector(server string, push Push) *Collector

NewCollector 创建并启动一个日志收集器 name: 日志收集器名称 push: 日志推送函数

func (*Logger) Panic

func (l *Logger) Panic(msg string)

func (*Logger) Warn

func (l *Logger) Warn(msg string)

type Message

type Message struct {
	Server string `json:"server"`
	Msg    string `json:"msg"`
}

type NacosLogger

type NacosLogger struct {
	Logger
}

func NewNacosLogger

func NewNacosLogger(logger *Logger) NacosLogger

NewNacosLogger 创建一个nacos日志对象

func (NacosLogger) Debug

func (l NacosLogger) Debug(args ...interface{})

func (NacosLogger) Debugf

func (l NacosLogger) Debugf(format string, args ...interface{})

func (NacosLogger) Error

func (l NacosLogger) Error(args ...interface{})

func (NacosLogger) Errorf

func (l NacosLogger) Errorf(format string, args ...interface{})

func (NacosLogger) Info

func (l NacosLogger) Info(args ...interface{})

func (NacosLogger) Infof

func (l NacosLogger) Infof(format string, args ...interface{})

func (NacosLogger) Warn

func (l NacosLogger) Warn(args ...interface{})

func (NacosLogger) Warnf

func (l NacosLogger) Warnf(format string, args ...interface{})

type Push

type Push func(message Message) error

Push 推送日志

Directories

Path Synopsis
gin module
gorm module
kratos module
lgin module
lgorm module
lkratos module

Jump to

Keyboard shortcuts

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