Documentation
¶
Overview ¶
Package log 重新定义标准日志接口,可以灵活适配各种日志框架。
Package log is a generated GoMock package.
Index ¶
- Constants
- Variables
- func Caller(skip int, fast bool) (file string, line int, loaded bool)
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func EnableDebug() bool
- func EnableError() bool
- func EnableFatal() bool
- func EnableInfo() bool
- func EnablePanic() bool
- func EnableTrace() bool
- func EnableWarn() bool
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func Reset()
- func SetLevel(level Level)
- func SetOutput(output Output)
- func T(a ...interface{}) []interface{}
- func Trace(args ...interface{})
- func Tracef(format string, args ...interface{})
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type BaseEntry
- func (e BaseEntry) Ctx(ctx context.Context) CtxEntry
- func (e BaseEntry) Debug(args ...interface{})
- func (e BaseEntry) Debugf(format string, args ...interface{})
- func (e BaseEntry) Error(args ...interface{})
- func (e BaseEntry) Errorf(format string, args ...interface{})
- func (e BaseEntry) Fatal(args ...interface{})
- func (e BaseEntry) Fatalf(format string, args ...interface{})
- func (e BaseEntry) GetContext() context.Context
- func (e BaseEntry) GetErrNo() ErrNo
- func (e BaseEntry) GetSkip() int
- func (e BaseEntry) GetTag() string
- func (e BaseEntry) Info(args ...interface{})
- func (e BaseEntry) Infof(format string, args ...interface{})
- func (e BaseEntry) Panic(args ...interface{})
- func (e BaseEntry) Panicf(format string, args ...interface{})
- func (e BaseEntry) Skip(n int) BaseEntry
- func (e BaseEntry) Tag(tag string) BaseEntry
- func (e BaseEntry) Trace(args ...interface{})
- func (e BaseEntry) Tracef(format string, args ...interface{})
- func (e BaseEntry) Warn(args ...interface{})
- func (e BaseEntry) Warnf(format string, args ...interface{})
- type CtxEntry
- func (e CtxEntry) Debug(args ...interface{})
- func (e CtxEntry) Debugf(format string, args ...interface{})
- func (e CtxEntry) Error(errno ErrNo, args ...interface{})
- func (e CtxEntry) Errorf(errno ErrNo, format string, args ...interface{})
- func (e CtxEntry) Fatal(args ...interface{})
- func (e CtxEntry) Fatalf(format string, args ...interface{})
- func (e CtxEntry) GetContext() context.Context
- func (e CtxEntry) GetErrNo() ErrNo
- func (e CtxEntry) GetSkip() int
- func (e CtxEntry) GetTag() string
- func (e CtxEntry) Info(args ...interface{})
- func (e CtxEntry) Infof(format string, args ...interface{})
- func (e CtxEntry) Panic(args ...interface{})
- func (e CtxEntry) Panicf(format string, args ...interface{})
- func (e CtxEntry) Skip(n int) CtxEntry
- func (e CtxEntry) Tag(tag string) CtxEntry
- func (e CtxEntry) Trace(args ...interface{})
- func (e CtxEntry) Tracef(format string, args ...interface{})
- func (e CtxEntry) Warn(args ...interface{})
- func (e CtxEntry) Warnf(format string, args ...interface{})
- type Entry
- type ErrNo
- type FuncOutput
- type Level
- type Message
- type MockOutput
- type MockOutputMockRecorder
- type Output
Constants ¶
View Source
const ( TraceLevel = Level(iota) DebugLevel InfoLevel WarnLevel ErrorLevel PanicLevel FatalLevel )
Variables ¶
View Source
var Console = FuncOutput(func(level Level, msg *Message) { defer func() { msg.Reuse() }() strLevel := strings.ToUpper(level.String()) if level >= ErrorLevel { strLevel = color.Red.Sprint(strLevel) } else if level == WarnLevel { strLevel = color.Yellow.Sprint(strLevel) } else if level == TraceLevel { strLevel = color.Green.Sprint(strLevel) } var buf bytes.Buffer for _, a := range msg.Args() { buf.WriteString(cast.ToString(a)) } strTime := msg.Time().Format("2006-01-02T15:04:05.000") fileLine := util.Contract(fmt.Sprintf("%s:%d", msg.File(), msg.Line()), 48) _, _ = fmt.Printf("[%s][%s][%s] %s\n", strLevel, strTime, fileLine, buf.String()) })
Console 将日志输出到控制台。
View Source
var UnknownError = NewErrNo(999, 999, "UNKNOWN ERROR")
Functions ¶
Types ¶
type BaseEntry ¶
type BaseEntry struct {
// contains filtered or unexported fields
}
func (BaseEntry) GetContext ¶
type CtxEntry ¶
type CtxEntry struct {
// contains filtered or unexported fields
}
func (CtxEntry) GetContext ¶
type FuncOutput ¶
FuncOutput 函数的形式自定义日志的输出格式。
func (FuncOutput) Do ¶
func (fn FuncOutput) Do(level Level, msg *Message)
type MockOutput ¶
type MockOutput struct {
// contains filtered or unexported fields
}
MockOutput is a mock of Output interface.
func NewMockOutput ¶
func NewMockOutput(ctrl *gomock.Controller) *MockOutput
NewMockOutput creates a new mock instance.
func (*MockOutput) EXPECT ¶
func (m *MockOutput) EXPECT() *MockOutputMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockOutputMockRecorder ¶
type MockOutputMockRecorder struct {
// contains filtered or unexported fields
}
MockOutputMockRecorder is the mock recorder for MockOutput.
func (*MockOutputMockRecorder) Do ¶
func (mr *MockOutputMockRecorder) Do(level, msg interface{}) *gomock.Call
Do indicates an expected call of Do.
Click to show internal directories.
Click to hide internal directories.