logx

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

README

goto logx

对 zap 的使用整合

配置读取逻辑

使用logger结构体,内含configx, 读取log文件存放路径及日志记录级别,强依赖于config mode

内部逻辑

内部使用 zap 进行日志记录,lumberjack 进行日志切割

扩充logger方法

type logCustom struct { *logCli }

func (l *logCustom) Fatal(msg string, args ...any) { l.logger.Sugar().Fatalf(msg, args...) }

替换logger实现

logCli 实现了 Logger interface,你也可以自己实现接口无缝替换

Documentation

Overview

无任何依赖的包变量logger,适用于直接导包的场景,解决实例化结构体没logger的问题

  • @Author: hugo
  • @Date: 2024-03-20 17:17
  • @LastEditors: hugo
  • @LastEditTime: 2024-04-02 15:02
  • @FilePath: \gotox\logx\zapBuilder.go
  • @Description: *
  • Copyright (c) 2024 by hugo, All Rights Reserved.

Index

Constants

View Source
const (
	DEFAULTLOGFILE  = "./log/dev.log"
	DEFAULTLOGLEVEl = "dev"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}
var Log Logger

func NewNoOpLogger

func NewNoOpLogger() Logger

type Logx

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

func New

func New(conf *configx.Configx) *Logx

func (*Logx) Debug

func (l *Logx) Debug(msg string, args ...any)

func (*Logx) Error

func (l *Logx) Error(msg string, args ...any)

func (*Logx) Info

func (l *Logx) Info(msg string, args ...any)

func (*Logx) Warn

func (l *Logx) Warn(msg string, args ...any)

type NoOpLogger

type NoOpLogger struct{}

func (*NoOpLogger) Debug

func (n *NoOpLogger) Debug(msg string, args ...any)

func (*NoOpLogger) Error

func (n *NoOpLogger) Error(msg string, args ...any)

func (*NoOpLogger) Info

func (n *NoOpLogger) Info(msg string, args ...any)

func (*NoOpLogger) Warn

func (n *NoOpLogger) Warn(msg string, args ...any)

Jump to

Keyboard shortcuts

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