log

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

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

Go to latest
Published: Jul 21, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiscardNonColorEscSeq outputMode
	OutputNonColorEscSeq
)

DiscardNonColorEscSeq supports the divided color escape sequence. But non-color escape sequence is not output. Please use the OutputNonColorEscSeq If you want to output a non-color escape sequences such as ncurses. However, it does not support the divided color escape sequence.

View Source
const (
	AdapterConsole = "console"
	AdapterFile    = "file"
	AdapterRemote  = "remote"
)

Variables

View Source
var (
	LevelPrefix = [log.LevelFatal + 1]string{"[D]", "[I]", "[W]", "[E]", "[P]", "[F]"}
)

Functions

func ColorByMethod

func ColorByMethod(cond bool, method string) string

ColorByMethod return color by http code GET return Blue POST return Cyan PUT return Yellow DELETE return Red PATCH return Green HEAD return Magenta OPTIONS return WHITE

func ColorByStatus

func ColorByStatus(cond bool, code int) string

ColorByStatus return color by http code 2xx return Green 3xx return White 4xx return Yellow 5xx return Red

func FormatHeader

func FormatHeader(buffer *bytes.Buffer, prefix string, t time.Time) int

func NewAnsiColorWriter

func NewAnsiColorWriter(w io.Writer) io.Writer

NewAnsiColorWriter creates and initializes a new ansiColorWriter using io.Writer w as its initial contents. In the console of Windows, which change the foreground and background colors of the text by the escape sequence. In the console of other systems, which writes to w all text.

func NewIoLogWriter

func NewIoLogWriter(wr io.Writer) *ioWriter

func NewModeAnsiColorWriter

func NewModeAnsiColorWriter(w io.Writer, mode outputMode) io.Writer

NewModeAnsiColorWriter create and initializes a new ansiColorWriter by specifying the outputMode.

func Register

func Register(adaptername string, adapterFn newLoggerFunc)

注册Adapter,如console/file/remote

func W32Debug

func W32Debug(msg string)

W32Debug Helper method to output colored logs in Windows terminals

Types

type Component

type Component struct {
	component.DefaultComponent
}

func (*Component) Create

func (l *Component) Create(instConfig *component.ComponentInstConfig) (interface{}, error)

type ILogger

type ILogger interface {
	Init(configor pbconfig.Configor) error
	SetLogLevel(level log.Level)
	WriteLog(logname, msg string, level log.Level, when time.Time, context, fields []log.Field)
	Destroy()
}

func NewConsole

func NewConsole() ILogger

NewConsole create ConsoleWriter returning as LoggerInterface.

type LogWrap

type LogWrap struct {
	Name      string // logger name
	OutWriter string // 指定输出
	Level     log.Level
	Msg       string
	Context   []log.Field
	Fields    []log.Field
	When      time.Time
}

type PBLogWriter

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

func NewLogWriter

func NewLogWriter(logWriterName string, configor pbconfig.Configor) (*PBLogWriter, error)

func (*PBLogWriter) Adapter

func (lw *PBLogWriter) Adapter() string

func (*PBLogWriter) Destroy

func (lw *PBLogWriter) Destroy()

func (*PBLogWriter) LogLevel

func (lw *PBLogWriter) LogLevel() log.Level

func (*PBLogWriter) Name

func (lw *PBLogWriter) Name() string

func (*PBLogWriter) SetLogLevel

func (lw *PBLogWriter) SetLogLevel(level log.Level)

log writer

func (*PBLogWriter) WriteLog

func (lw *PBLogWriter) WriteLog(logname, msg string, level log.Level, when time.Time, context, fields []log.Field)

type StrEncoder

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

func (StrEncoder) EncodeBool

func (s StrEncoder) EncodeBool(key string, val bool)

func (StrEncoder) EncodeDuration

func (s StrEncoder) EncodeDuration(key string, val time.Duration)

func (StrEncoder) EncodeFloat64

func (s StrEncoder) EncodeFloat64(key string, val float64)

func (StrEncoder) EncodeInt

func (s StrEncoder) EncodeInt(key string, val int)

func (StrEncoder) EncodeInt64

func (s StrEncoder) EncodeInt64(key string, val int64)

func (StrEncoder) EncodeObject

func (s StrEncoder) EncodeObject(key string, val interface{})

func (StrEncoder) EncodeString

func (s StrEncoder) EncodeString(key string, val string)

func (StrEncoder) EncodeType

func (s StrEncoder) EncodeType(key string, val reflect.Type)

func (StrEncoder) EncodeUint

func (s StrEncoder) EncodeUint(key string, val uint)

func (StrEncoder) EncodeUint64

func (s StrEncoder) EncodeUint64(key string, val uint64)

Jump to

Keyboard shortcuts

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