glog

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

README

glog

自用的golang日志库

GoReport Gitea Release Go.Dev reference

import "git.ksyaki.co/gomod/glog"

类型

使用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

	MaskStd = MaskINFO | MaskWARNING | MaskERROR | MaskFATAL
	MaskAll = MaskUNKNOWN | MaskDEBUG | MaskTRACE | MaskINFO | MaskWARNING | MaskERROR | MaskFATAL
)
View Source
const (
	FlagDate = 1 << iota
	FlagTime
	FlagLongFile
	FlagShortFile
	FlagFunc
	FlagPrefix
	FlagSuffix

	FlagStd = FlagDate | FlagTime | FlagPrefix
	FlagAll = FlagDate | FlagTime | FlagShortFile | FlagFunc | FlagPrefix | FlagSuffix
)

Variables

This section is empty.

Functions

func Close

func Close()

func CloseFile

func CloseFile()

func CloseStderr

func CloseStderr()

func CloseStdout

func CloseStdout()

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 GetFlag

func GetFlag() uint32

func GetMask

func GetMask() uint32

func Info

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

func SetFlag

func SetFlag(f uint32)

func SetLogFile

func SetLogFile(path string) error

func SetMask

func SetMask(m uint32)

func SetSeparatorEnd

func SetSeparatorEnd(sep string)

func SetSeparatorEndEnd

func SetSeparatorEndEnd(end string)

func SetSeparatorStart

func SetSeparatorStart(sep string)

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 Paper

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

func NewPaperFromFile

func NewPaperFromFile(file *os.File) *Paper

func (*Paper) Close

func (f *Paper) Close() error

func (*Paper) Ready

func (f *Paper) Ready() bool

func (*Paper) SetFile

func (f *Paper) SetFile(file *os.File)

func (*Paper) WriteString

func (f *Paper) WriteString(s string)

Jump to

Keyboard shortcuts

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