logger

package
v0.0.0-...-5b18574 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

logger.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

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

func Error

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

func Fatal

func Fatal(format string, v ...interface{})

func Info

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

func SetColor

func SetColor(enable bool)

func SetIncludeTrace

func SetIncludeTrace(include bool)

func SetLevel

func SetLevel(level LogLevel)

================ 全局函数 ================

func SetOutput

func SetOutput(w io.Writer)

func SetTimeFormat

func SetTimeFormat(format string)

func Warn

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

Types

type LogLevel

type LogLevel int

日志级别类型

const (
	DEBUG LogLevel = iota
	INFO
	WARN
	ERROR
	FATAL
)

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

Logger 结构体

func NewLogger

func NewLogger(out io.Writer, minLevel LogLevel, includeTrace bool) *Logger

创建新日志实例

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

各级别日志方法

func (*Logger) Error

func (l *Logger) Error(format string, v ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(format string, v ...interface{})

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

func (*Logger) SetColor

func (l *Logger) SetColor(enable bool)

启用或禁用颜色输出

func (*Logger) SetIncludeTrace

func (l *Logger) SetIncludeTrace(include bool)

设置是否包含调用追踪

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

设置日志级别

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

设置输出目标

func (*Logger) SetTimeFormat

func (l *Logger) SetTimeFormat(format string)

设置时间格式 (空字符串表示不使用时间)

func (*Logger) Warn

func (l *Logger) Warn(format string, v ...interface{})

Jump to

Keyboard shortcuts

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