| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 | 
							- package log
 
- import (
 
- 	"fmt"
 
- 	"io"
 
- 	"log"
 
- 	"os"
 
- )
 
- const (
 
- 	LevelNone uint8 = iota
 
- 	LevelError
 
- 	LevelWarning
 
- 	LevelInfo
 
- 	LevelDebug
 
- )
 
- const (
 
- 	Flag = log.LstdFlags | log.Llongfile
 
- 	callDepth = 2
 
- )
 
- var (
 
- 	debug   = log.New(os.Stdout, "[D] ", Flag)
 
- 	info    = log.New(os.Stdout, "[I] ", Flag)
 
- 	warning = log.New(os.Stdout, "[W] ", Flag)
 
- 	errorLg = log.New(os.Stdout, "[E] ", Flag)
 
- 	defaultLevel uint8
 
- )
 
- func SetLevel(level uint8) {
 
- 	defaultLevel = level
 
- }
 
- func SetOutput(w io.Writer) {
 
- 	debug.SetOutput(w)
 
- 	info.SetOutput(w)
 
- 	warning.SetOutput(w)
 
- 	errorLg.SetOutput(w)
 
- }
 
- func Debug(f string, v ...interface{}) {
 
- 	if defaultLevel < LevelDebug {
 
- 		return
 
- 	}
 
- 	_ = debug.Output(callDepth, fmt.Sprintf(f, v...))
 
- }
 
- func Info(f string, v ...interface{}) {
 
- 	if defaultLevel < LevelInfo {
 
- 		return
 
- 	}
 
- 	_ = info.Output(callDepth, fmt.Sprintf(f, v...))
 
- }
 
- func Warning(f string, v ...interface{}) {
 
- 	if defaultLevel < LevelWarning {
 
- 		return
 
- 	}
 
- 	_ = warning.Output(callDepth, fmt.Sprintf(f, v...))
 
- }
 
- func Error(f string, v ...interface{}) {
 
- 	if defaultLevel < LevelError {
 
- 		return
 
- 	}
 
- 	_ = errorLg.Output(callDepth, fmt.Sprintf(f, v...))
 
- }
 
- func Panic(f string, v ...interface{}) {
 
- 	s := fmt.Sprintf(f, v...)
 
- 	_ = errorLg.Output(callDepth, s)
 
- 	panic(s)
 
- }
 
- func init() {
 
- 	defaultLevel = LevelDebug
 
- }
 
 
  |