glog

package
v0.0.0-...-2bcc11b Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = &DefaultImpl{}

Functions

func AssertOk

func AssertOk(err error, wrapMsg ...string)

func AssertTrue

func AssertTrue(express bool, wrapMsg ...string)

func Debgf

func Debgf(format string, a ...interface{})

func Erro

func Erro(err error, wrapMsg ...string)

func Errof

func Errof(format string, a ...interface{})

func Fata

func Fata(err error, wrapMsg ...string)

func Fataf

func Fataf(format string, a ...interface{})

func Infof

func Infof(format string, a ...interface{})

func Init

func Init(saveDisk bool)

func SetClock

func SetClock(c gtime.Clock)

func Warnf

func Warnf(format string, a ...interface{})

Types

type Config

type Config struct {
	SaveDisk       bool
	SaveDir        string
	FileNameFormat string
	PrintScreen    bool

	MachId  string
	AppName string
}

func DefaultConfig

func DefaultConfig() (*Config, error)

type DefaultImpl

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

func NewInsideLogger

func NewInsideLogger(c gtime.Clock) *DefaultImpl

func (*DefaultImpl) AssertOk

func (lgz *DefaultImpl) AssertOk(err error, wrapMsg ...string)

func (*DefaultImpl) AssertTrue

func (lgz *DefaultImpl) AssertTrue(express bool, wrapMsg ...string)

func (*DefaultImpl) Debgf

func (lgz *DefaultImpl) Debgf(format string, a ...interface{})

func (*DefaultImpl) Destroy

func (lgz *DefaultImpl) Destroy()

func (*DefaultImpl) Erro

func (lgz *DefaultImpl) Erro(err error, wrapMsg ...string)

func (*DefaultImpl) Errof

func (lgz *DefaultImpl) Errof(format string, a ...interface{})

func (*DefaultImpl) Fata

func (lgz *DefaultImpl) Fata(err error, wrapMsg ...string)

func (*DefaultImpl) Fataf

func (lgz *DefaultImpl) Fataf(format string, a ...interface{})

func (*DefaultImpl) Flush

func (lgz *DefaultImpl) Flush()

func (*DefaultImpl) Infof

func (lgz *DefaultImpl) Infof(format string, a ...interface{})

func (*DefaultImpl) Init

func (lgz *DefaultImpl) Init(config *Config) error

注意,这里的receiver必须用*DefaultImpl,不可以用logger,否则conf将无法保存进l里面去

func (*DefaultImpl) Logging

func (lgz *DefaultImpl) Logging(log LogItem) error

func (*DefaultImpl) LoggingEx

func (lgz *DefaultImpl) LoggingEx(level Level, text string, tags map[string]string) error

func (*DefaultImpl) SetClock

func (lgz *DefaultImpl) SetClock(c gtime.Clock)

func (*DefaultImpl) Warnf

func (lgz *DefaultImpl) Warnf(format string, a ...interface{})

func (*DefaultImpl) WriteMsg

func (lgz *DefaultImpl) WriteMsg(when time.Time, msg string, level Level) error

Output to disk and screen if user want it

type Interface

type Interface interface {
	Debgf(format string, a ...interface{})
	Infof(format string, a ...interface{})
	Warnf(format string, a ...interface{})
	Errof(format string, a ...interface{})
	Fataf(format string, a ...interface{})
	Erro(err error, wrapMsg ...string)
	Fata(err error, wrapMsg ...string)
	AssertOk(err error, wrapMsg ...string)
	AssertTrue(express bool, wrapMsg ...string)
}

type Level

type Level string
const (
	LevelDebg Level = "DEBG"
	LevelInfo Level = "INFO"
	LevelWarn Level = "WARN"
	LevelErro Level = "ERRO"
	LevelFata Level = "FATA"
)

type LogItem

type LogItem struct {
	Time  time.Time
	Level Level
	Text  string
	Tags  map[string]string `json:"ExtTags,omitempty" bson:"ExtTags,omitempty"`
}

func NewLogItem

func NewLogItem(level Level, time time.Time, text string) LogItem

func (*LogItem) GetExtTag

func (l *LogItem) GetExtTag(key string) string

func (*LogItem) GetExtTagEx

func (l *LogItem) GetExtTagEx(key string) (string, bool)

func (*LogItem) SetExtTag

func (l *LogItem) SetExtTag(key, value string) *LogItem

Jump to

Keyboard shortcuts

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