1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package log
- import (
- "log"
- "os"
- )
- const (
- calldepth = 3
- )
- var l Logger = &defaultLogger{log.New(os.Stdout, "", log.LstdFlags|log.Lshortfile)}
- type Logger interface {
- Debug(v ...interface{})
- Debugf(format string, v ...interface{})
- Info(v ...interface{})
- Infof(format string, v ...interface{})
- Warn(v ...interface{})
- Warnf(format string, v ...interface{})
- Error(v ...interface{})
- Errorf(format string, v ...interface{})
- Fatal(v ...interface{})
- Fatalf(format string, v ...interface{})
- Panic(v ...interface{})
- Panicf(format string, v ...interface{})
- }
- type Handler interface {
- Handle(v ...interface{})
- }
- func SetLogger(logger Logger) {
- l = logger
- }
- func SetDummyLogger() {
- l = &dummyLogger{}
- }
- func Debug(v ...interface{}) {
- l.Debug(v...)
- }
- func Debugf(format string, v ...interface{}) {
- l.Debugf(format, v...)
- }
- func Info(v ...interface{}) {
- l.Info(v...)
- }
- func Infof(format string, v ...interface{}) {
- l.Infof(format, v...)
- }
- func Warn(v ...interface{}) {
- l.Warn(v...)
- }
- func Warnf(format string, v ...interface{}) {
- l.Warnf(format, v...)
- }
- func Error(v ...interface{}) {
- l.Error(v...)
- }
- func Errorf(format string, v ...interface{}) {
- l.Errorf(format, v...)
- }
- func Fatal(v ...interface{}) {
- l.Fatal(v...)
- }
- func Fatalf(format string, v ...interface{}) {
- l.Fatalf(format, v...)
- }
- func Panic(v ...interface{}) {
- l.Panic(v...)
- }
- func Panicf(format string, v ...interface{}) {
- l.Panicf(format, v...)
- }
- func Handle(v ...interface{}) {
- if handle, ok := l.(Handler); ok {
- handle.Handle(v...)
- }
- }
|