log

package
v0.0.0-...-303e327 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 12 Imported by: 25

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeDefaultLevelHandler

func ChangeDefaultLevelHandler() (string, http.HandlerFunc)

ChangeDefaultLevelHandler returns http handler of default log level modify API

func Debug

func Debug(v ...interface{})

func Debugf

func Debugf(format string, v ...interface{})

func Error

func Error(v ...interface{})

func Errorf

func Errorf(format string, v ...interface{})

func Fatal

func Fatal(v ...interface{})

func Fatalf

func Fatalf(format string, v ...interface{})

func Info

func Info(v ...interface{})

func Infof

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

func Panic

func Panic(v ...interface{})

func Panicf

func Panicf(format string, v ...interface{})

func Printf

func Printf(format string, v ...interface{})

func Println

func Println(v ...interface{})

func SetOutput

func SetOutput(w io.Writer)

func SetOutputLevel

func SetOutputLevel(lvl Level)

func Warn

func Warn(v ...interface{})

func Warnf

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

Types

type BaseLogger

type BaseLogger interface {
	Printf(format string, v ...interface{})
	Println(v ...interface{})
	Debugf(format string, v ...interface{})
	Debug(v ...interface{})
	Infof(format string, v ...interface{})
	Info(v ...interface{})
	Warnf(format string, v ...interface{})
	Warn(v ...interface{})
	Errorf(format string, v ...interface{})
	Error(v ...interface{})
	Fatalf(format string, v ...interface{})
	Fatal(v ...interface{})
	Panicf(format string, v ...interface{})
	Panic(v ...interface{})
}

BaseLogger defines interface of application log apis.

type Level

type Level int

Level type log level

const (
	Ldebug Level = iota
	Linfo
	Lwarn
	Lerror
	Lpanic
	Lfatal
)

defines log level

func GetOutputLevel

func GetOutputLevel() Level

func (*Level) UnmarshalJSON

func (l *Level) UnmarshalJSON(data []byte) error

UnmarshalJSON unserialize log level with json. Try compatible digit firstly then string.

func (*Level) UnmarshalYAML

func (l *Level) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unserialize log level with yaml.

type Logger

type Logger interface {
	BaseLogger

	// atomically control log level
	GetOutputLevel() Level
	SetOutputLevel(logLevel Level)
	SetOutput(w io.Writer)
	Output(id string, lvl Level, calldepth int, s string) error

	// implement raft Logger with these two function
	Warningf(format string, v ...interface{})
	Warning(v ...interface{})
}

Logger a implemented logger should implements all these function.

var DefaultLogger Logger

DefaultLogger default logger initial with os.Stderr.

func New

func New(out io.Writer, calldepth int) Logger

New return a logger with default level Linfo. output buffer with reused bytes pool.

Jump to

Keyboard shortcuts

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