logutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

logutil包提供一个日志对象 日志对象提供一下功能:

1、提供 Panic Fatal Error Warn Info Debug Trace 七个日志级别,以及动态设置
2、支持指定日志路径与日志文件名
3、支持动态设置tag过滤

Index

Constants

View Source
const (
	Value_Nil = "<nil>"
)

Variables

This section is empty.

Functions

func GetCaller

func GetCaller(skip int) string

获取调用函数及行号

func GetCallerStack

func GetCallerStack(skip int) string

获取当前调用栈

func Printf added in v0.1.0

func Printf(v any, alignment bool) string

Types

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.

func (Frame) PC

func (f Frame) PC() uintptr

PC returns the program counter for this frame; multiple frames may have the same PC value.

type Logger

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

日志对象

func NewLogger

func NewLogger(ctx context.Context, logPath, logName, logFormatter string) *Logger

实例化一个日志对象

func (*Logger) AddHook_FileLog

func (l *Logger) AddHook_FileLog(logPath, logName string)

将日志输出到指定文件

func (*Logger) AddHook_LogService

func (l *Logger) AddHook_LogService(callback port.LogServiceCallBack)

将日志输出到指定服务

func (*Logger) AddTagFilter

func (l *Logger) AddTagFilter(tag string)

添加一个过滤标签

func (*Logger) Debugf

func (l *Logger) Debugf(tag, format string, args ...any)

Debug log

func (*Logger) Debugf_Skip

func (l *Logger) Debugf_Skip(skip int, tag, format string, args ...any)

Debug log, but can specify caller skip

func (*Logger) DelTagFilter

func (l *Logger) DelTagFilter(tag string)

移除一个过滤标签

func (*Logger) Errorf

func (l *Logger) Errorf(tag, format string, args ...any)

Error log

func (*Logger) Errorf_Skip

func (l *Logger) Errorf_Skip(skip int, tag, format string, args ...any)

Error log, but can specify caller skip

func (*Logger) Fatalf

func (l *Logger) Fatalf(tag, format string, args ...any)

Fatal log

func (*Logger) Fatalf_Skip

func (l *Logger) Fatalf_Skip(skip int, tag, format string, args ...any)

Fatal log, but can specify caller skip

func (*Logger) Infof

func (l *Logger) Infof(tag, format string, args ...any)

Info log

func (*Logger) Infof_Skip

func (l *Logger) Infof_Skip(skip int, tag, format string, args ...any)

Info log, but can specify caller skip

func (*Logger) Panicf

func (l *Logger) Panicf(tag, format string, args ...any)

Panic log

func (*Logger) Panicf_Skip

func (l *Logger) Panicf_Skip(skip int, tag, format string, args ...any)

Panic log, but can specify caller skip

func (*Logger) ResetFilter

func (l *Logger) ResetFilter()

重置过滤标签

func (*Logger) SetLevel

func (l *Logger) SetLevel(level string) error

设置日志等级

func (*Logger) Tracef

func (l *Logger) Tracef(tag, format string, args ...any)

Trace log

func (*Logger) Tracef_Skip

func (l *Logger) Tracef_Skip(skip int, tag, format string, args ...any)

Trace log, but can specify caller skip

func (*Logger) Wait

func (l *Logger) Wait()

等待文件Writer结束

func (*Logger) Warnf

func (l *Logger) Warnf(tag, format string, args ...any)

Warning log

func (*Logger) Warnf_Skip

func (l *Logger) Warnf_Skip(skip int, tag, format string, args ...any)

Warning log, but can specify caller skip

type MyPrintf added in v0.1.0

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

type Stack

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

stack represents a stack of program counters.

func (Stack) String

func (s Stack) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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