glog

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: GPL-2.0 Imports: 7 Imported by: 1

README

glog

自用的golang日志库

类型

使用SetMask(m int)设置每种消息是否输出

  • Unknown(format string, values ...any): 写入os.Stdout
  • Debug(format string, values ...any): 写入os.Stdout
  • Trace(format string, values ...any): 写入os.Stdout
  • Info(format string, values ...any): 写入os.Stdout
  • Warning(format string, values ...any): 写入os.Stdout
  • Error(format string, values ...any): 写入os.Stderr
  • Fatal(format string, values ...any): 写入os.Stderr

前缀

支持添加时间、类型、调用位置,使用SetFlag(f int)设置前缀。

文件

支持在显示在控制台的同时写入文件,通过SetLogFile(path string) error设置文件,设置后会自动写入此文件。

通过CloseFile()关闭文件,关闭后不再写入文件

Documentation

Index

Constants

View Source
const (
	MaskUNKNOWN = 1 << iota
	MaskDEBUG
	MaskTRACE
	MaskINFO
	MaskWARNING
	MaskERROR
	MaskFATAL
	MaskStdMask = MaskINFO | MaskWARNING | MaskERROR | MaskFATAL
	MaskStdAll  = MaskUNKNOWN | MaskDEBUG | MaskTRACE | MaskINFO | MaskWARNING | MaskERROR | MaskFATAL
)
View Source
const (
	FlagDate = 1 << iota
	FlagTime
	FlagLongFile
	FlagShortFile
	FlagPrefix
	FlagStdFlag = FlagDate | FlagTime
)

Variables

This section is empty.

Functions

func CloseFile

func CloseFile()

func Debug

func Debug(format string, values ...any)

func Error

func Error(format string, values ...any)

func Fatal

func Fatal(format string, values ...any)

func Info

func Info(format string, values ...any)

func SetFlag

func SetFlag(f int)

func SetLogFile

func SetLogFile(path string) error

func SetMask

func SetMask(m int)

func Trace

func Trace(format string, values ...any)

func Unknown

func Unknown(format string, values ...any)

func Warning

func Warning(format string, values ...any)

Types

type File

type File struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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