log

package
v0.0.0-...-7cfd609 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Red    = color.New(color.FgHiRed).SprintFunc()
	Blue   = color.New(color.FgHiBlue).SprintFunc()
	Yellow = color.New(color.FgHiYellow).SprintFunc()
	Green  = color.New(color.FgHiGreen).SprintFunc()
)
View Source
var ColorResetStr = "\x1b[0m"
View Source
var LenColorResetStr = len(ColorResetStr)

Functions

func GetKratosLogHelper

func GetKratosLogHelper() *log.Helper

func GetKratosLogger

func GetKratosLogger() log.Logger

func GetLogPath

func GetLogPath(logDir string, serviceName string) string

func NewAsyncWriter

func NewAsyncWriter(w io.Writer) *law.WriteAsyncer

func NewFileWriter

func NewFileWriter(logPath string) *lumberjack.Logger

func SetGlobalLogger

func SetGlobalLogger(l *Logger)

func Sprint

func Sprint(args ...interface{}) string

Sprint 格式化参数,每个参数中间隔一个空格,返回格式化后的字符串 高效实现:使用strings.Builder预分配容量,减少内存分配,比fmt.Sprint更高效且确保参数间有空格

func SugaredLogger

func SugaredLogger() *zap.SugaredLogger

Types

type CustomEncoder

type CustomEncoder struct {
	zapcore.Encoder
}

func (*CustomEncoder) EncodeEntry

func (c *CustomEncoder) EncodeEntry(entry zapcore.Entry, fields []zap.Field) (*buffer.Buffer, error)

type Logger

type Logger struct {
	*zap.Logger
}

func GetLogger

func GetLogger() *Logger

func NewLogger

func NewLogger(
	mode int,
	level string,
	logDir string,
	appName string,
) (*Logger, error)

Jump to

Keyboard shortcuts

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