glog

package module
v0.2.1 Latest Latest
Warning

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

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

README

glog

自用的golang日志库

import "github.com/AkvicorEdwards/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 added in v0.2.1

func Close()

func CloseFile

func CloseFile()

func CloseStderr added in v0.2.1

func CloseStderr()

func CloseStdout added in v0.2.1

func CloseStdout()

func Debug

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

func Error added in v0.1.0

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

func Fatal

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

func GetFlag added in v0.2.1

func GetFlag() uint32

func GetMask added in v0.2.1

func GetMask() uint32

func Info

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

func SetFlag added in v0.1.0

func SetFlag(f uint32)

func SetLogFile

func SetLogFile(path string) error

func SetMask

func SetMask(m uint32)

func SetSeparatorEnd added in v0.2.1

func SetSeparatorEnd(sep string)

func SetSeparatorEndEnd added in v0.2.1

func SetSeparatorEndEnd(end string)

func SetSeparatorStart added in v0.2.1

func SetSeparatorStart(sep string)

func Trace added in v0.1.0

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

func Unknown added in v0.1.0

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

func Warning

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

Types

type Paper added in v0.2.1

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

func NewPaperFromFile added in v0.2.1

func NewPaperFromFile(file *os.File) *Paper

func (*Paper) Close added in v0.2.1

func (f *Paper) Close() error

func (*Paper) Ready added in v0.2.1

func (f *Paper) Ready() bool

func (*Paper) SetFile added in v0.2.1

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

func (*Paper) WriteString added in v0.2.1

func (f *Paper) WriteString(s string)

Jump to

Keyboard shortcuts

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