blog

package
v0.0.0-...-6ac6f58 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Info  = glog.Infof
	Infof = glog.Infof

	Warn  = glog.Warningf
	Warnf = glog.Warningf

	Error  = glog.Errorf
	Errorf = glog.Errorf

	Fatal  = glog.Fatal
	Fatalf = glog.Fatalf

	Debugf = glog.V(3).Infof

	V = glog.V
)

Functions

func CloseLogs

func CloseLogs()

CloseLogs will flush the logs in cache out.

func InitLogs

func InitLogs(logConfig conf.LogConfig)

InitLogs initializes logs the way we want for blog.

func SetStderrLevel

func SetStderrLevel(level StderrLevel)

SetStderrLevel 设置高于等于level的内容会被打到stderr中

func SetV

func SetV(level int32)

SetV set the logs output level in runtime.

Types

type GlogWriter

type GlogWriter struct{}

GlogWriter serves as a bridge between the standard log package and the glog package.

func (GlogWriter) Write

func (writer GlogWriter) Write(data []byte) (n int, err error)

Write implements the io.Writer interface.

type StderrLevel

type StderrLevel int32
const (
	StderrLevelInfo StderrLevel = iota
	StderrLevelWarning
	StderrLevelError
	StderrLevelNothing
)

type WrapFunc

type WrapFunc func(string, ...interface{}) string

WrapFunc take the param the same as glog.Infof, and return string.

type Wrapper

type Wrapper struct {
	Handler WrapFunc
	// contains filtered or unexported fields
}

Wrapper use WrapFunc to handle the log message before send it to glog. Can be use as:

var handler blog.WrapFunc = func(format string, args ...interface{}) string {
    src := fmt.Sprintf(format, args...)
    dst := regexp.MustCompile("boy").ReplaceAllString(src, "man")
}
blog.Wrapper(handler).V(2).Info("hello boy")

And it will flush as:

I0104 09:44:27.796409   16233 blog.go:21] hello man

func Wrap

func Wrap(handler WrapFunc) *Wrapper

Wrap get a Wrapper with given WrapFunc.

func (*Wrapper) Error

func (w *Wrapper) Error(format string, args ...interface{})

Error write the error log.

func (*Wrapper) Fatal

func (w *Wrapper) Fatal(format string, args ...interface{})

Fatal write the fatal log.

func (*Wrapper) Info

func (w *Wrapper) Info(format string, args ...interface{})

Info write the info log.

func (*Wrapper) V

func (w *Wrapper) V(level glog.Level) *Wrapper

V specific the log level to print.

func (*Wrapper) Warn

func (w *Wrapper) Warn(format string, args ...interface{})

Warn write the warn log.

Directories

Path Synopsis
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.

Jump to

Keyboard shortcuts

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