func Trace(f interface{}, v ...interface{}) {
	defaultLogger.Trace(formatLog(f, v...))
}
Trace logs a message at trace level.
package logger
import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
	"runtime"
	"strings"
	"sync"
	"time"
)
var defaultLogger *LocalLogger
const (
	LevelEmergency     = iota  
	LevelAlert                 
	LevelCritical              
	LevelError                 
	LevelWarning               
	LevelInformational         
	LevelDebug                 
	LevelTrace                 
)
var LevelMap = map[string]int{
	"EMER": LevelEmergency,
	"ALRT": LevelAlert,
	"CRIT": LevelCritical,
	"EROR": LevelError,
	"WARN": LevelWarning,
	"INFO": LevelInformational,
	"DEBG": LevelDebug,
	"TRAC": LevelTrace,
}
var adapters = make(map[string]Logger)
var levelPrefix = [LevelTrace + 1]string{
	"EMER",
	"ALRT",
	"CRIT",
	"EROR",
	"WARN",
	"INFO",
	"DEBG",
	"TRAC",
}
const (
	logTimeDefaultFormat = "2006-01-02 15:04:05"  
	AdapterConsole       = "console"              
	AdapterFile          = "file"                 
	AdapterConn          = "conn"                 
)
type Logger interface {
	Init(config string) error
	LogWrite(when time.Time, msg interface{}, level int) error
	Destroy()
}
func Register(name string, log Logger) {
	if log == nil {
		panic("logs: Register provide is nil")
	}
	if _, ok := adapters[name]; ok {
		panic("logs: Register called twice for provider " + name)
	}
	adapters[name] = log
}
type loginfo struct {
	Time    string
	Level   string
	Path    string
	Name    string
	Content string
}
type nameLogger struct {
	Logger
	name   string
	config string
}
type LocalLogger struct {
	lock       sync.Mutex
	init       bool
	outputs    []*nameLogger
	appName    string
	callDepth  int
	timeFormat string
	usePath    bool
}
func NewLogger(depth ...int) *LocalLogger {
	dep := append(depth, 2)[0]
	l := new(LocalLogger)
	appSn := os.Getenv("APPSN")
	if appSn == "" {
		appSn = "NONE"
	}
	l.appName = "[" + appSn + "]"
	l.callDepth = dep
	l.SetLogger(AdapterConsole)
	l.timeFormat = logTimeDefaultFormat
	return l
}
type logConfig struct {
	TimeFormat string         `json:"TimeFormat"`
	Console    *consoleLogger `json:"Console,omitempty"`
	File       *fileLogger    `json:"File,omitempty"`
	Conn       *connLogger    `json:"Conn,omitempty"`
}
func init() {
	defaultLogger = NewLogger(3)
}
func (this *LocalLogger) SetLogger(adapterName string, configs ...string) error {
	this.lock.Lock()
	defer this.lock.Unlock()
	if !this.init {
		this.outputs = []*nameLogger{}
		this.init = true
	}
	config := append(configs, "{}")[0]
	var num int = -1
	var i int
	var l *nameLogger
	for i, l = range this.outputs {
		if l.name == adapterName {
			if l.config == config {
				return fmt.Errorf("you have set same config for this adaptername %s", adapterName)
			}
			l.Logger.Destroy()
			num = i
			break
		}
	}
	logger, ok := adapters[adapterName]
	if !ok {
		return fmt.Errorf("unknown adaptername %s (forgotten Register?)", adapterName)
	}
	err := logger.Init(config)
	if err != nil {
		fmt.Fprintf(os.Stderr, "logger Init <%s> err:%v, %s output ignore!\n",
			adapterName, err, adapterName)
		return err
	}
	if num >= 0 {
		this.outputs[i] = &nameLogger{name: adapterName, Logger: logger, config: config}
		return nil
	}
	this.outputs = append(this.outputs, &nameLogger{name: adapterName, Logger: logger, config: config})
	return nil
}
func (this *LocalLogger) DelLogger(adapterName string) error {
	this.lock.Lock()
	defer this.lock.Unlock()
	outputs := []*nameLogger{}
	for _, lg := range this.outputs {
		if lg.name == adapterName {
			lg.Destroy()
		} else {
			outputs = append(outputs, lg)
		}
	}
	if len(outputs) == len(this.outputs) {
		return fmt.Errorf("logs: unknown adaptername %s (forgotten Register?)", adapterName)
	}
	this.outputs = outputs
	return nil
}
func (this *LocalLogger) SetLogPath(bPath bool) {
	this.usePath = bPath
}
func (this *LocalLogger) writeToLoggers(when time.Time, msg *loginfo, level int) {
	for _, l := range this.outputs {
		if l.name == AdapterConn {
			err := l.LogWrite(when, msg, level)
			if err != nil {
				fmt.Fprintf(os.Stderr, "unable to WriteMsg to adapter:%v,error:%v\n", l.name, err)
			}
			continue
		}
		strLevel := " [" + msg.Level + "] "
		strPath := "[" + msg.Path + "] "
		if !this.usePath {
			strPath = ""
		}
		msgStr := when.Format(this.timeFormat) + strLevel + strPath + msg.Content
		err := l.LogWrite(when, msgStr, level)
		if err != nil {
			fmt.Fprintf(os.Stderr, "unable to WriteMsg to adapter:%v,error:%v\n", l.name, err)
		}
	}
}
func (this *LocalLogger) writeMsg(logLevel int, msg string, v ...interface{}) error {
	if !this.init {
		this.SetLogger(AdapterConsole)
	}
	msgSt := new(loginfo)
	src := ""
	if len(v) > 0 {
		msg = fmt.Sprintf(msg, v...)
	}
	when := time.Now()
	if this.usePath {
		_, file, lineno, ok := runtime.Caller(this.callDepth)
		var strim = "/"
		if ok {
			codeArr := strings.Split(file, strim)
			code := codeArr[len(codeArr)-1]
			src = strings.Replace(
				fmt.Sprintf("%s:%d", code, lineno), "%2e", ".", -1)
		}
	}
	msgSt.Level = levelPrefix[logLevel]
	msgSt.Path = src
	msgSt.Content = msg
	msgSt.Name = this.appName
	msgSt.Time = when.Format(this.timeFormat)
	this.writeToLoggers(when, msgSt, logLevel)
	return nil
}
func (this *LocalLogger) Fatal(format string, args ...interface{}) {
	this.Emer("###Exec Panic:"+format, args...)
	os.Exit(1)
}
func (this *LocalLogger) Panic(format string, args ...interface{}) {
	this.Emer("###Exec Panic:"+format, args...)
	panic(fmt.Sprintf(format, args...))
}
func (this *LocalLogger) Emer(format string, v ...interface{}) {
	this.writeMsg(LevelEmergency, format, v...)
}
func (this *LocalLogger) Alert(format string, v ...interface{}) {
	this.writeMsg(LevelAlert, format, v...)
}
func (this *LocalLogger) Crit(format string, v ...interface{}) {
	this.writeMsg(LevelCritical, format, v...)
}
func (this *LocalLogger) Error(format string, v ...interface{}) {
	this.writeMsg(LevelError, format, v...)
}
func (this *LocalLogger) Warn(format string, v ...interface{}) {
	this.writeMsg(LevelWarning, format, v...)
}
func (this *LocalLogger) Info(format string, v ...interface{}) {
	this.writeMsg(LevelInformational, format, v...)
}
func (this *LocalLogger) Debug(format string, v ...interface{}) {
	this.writeMsg(LevelDebug, format, v...)
}
func (this *LocalLogger) Trace(format string, v ...interface{}) {
	this.writeMsg(LevelTrace, format, v...)
}
func (this *LocalLogger) Close() {
	for _, l := range this.outputs {
		l.Destroy()
	}
	this.outputs = nil
}
func (this *LocalLogger) Reset() {
	for _, l := range this.outputs {
		l.Destroy()
	}
	this.outputs = nil
}
func (this *LocalLogger) SetCallDepth(depth int) {
	this.callDepth = depth
}
func GetlocalLogger() *LocalLogger {
	return defaultLogger
}
func Reset() {
	defaultLogger.Reset()
}
func SetLogPath(show bool) {
	defaultLogger.SetLogPath(show)
}
func SetLogger(param ...string) error {
	if 0 == len(param) {
		defaultLogger.SetLogger(AdapterConsole)
		return nil
	}
	c := param[0]
	conf := new(logConfig)
	err := json.Unmarshal([]byte(c), conf)
	if err != nil {  
		fd, err := os.Open(c)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Could not open %s for configure: %s\n", c, err)
			os.Exit(1)
			return err
		}
		contents, err := ioutil.ReadAll(fd)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Could not read %s: %s\n", c, err)
			os.Exit(1)
			return err
		}
		err = json.Unmarshal(contents, conf)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Could not Unmarshal %s: %s\n", contents, err)
			os.Exit(1)
			return err
		}
	}
	if conf.TimeFormat != "" {
		defaultLogger.timeFormat = conf.TimeFormat
	}
	if conf.Console != nil {
		console, _ := json.Marshal(conf.Console)
		defaultLogger.SetLogger(AdapterConsole, string(console))
	}
	if conf.File != nil {
		file, _ := json.Marshal(conf.File)
		defaultLogger.SetLogger(AdapterFile, string(file))
	}
	if conf.Conn != nil {
		conn, _ := json.Marshal(conf.Conn)
		defaultLogger.SetLogger(AdapterConn, string(conn))
	}
	return nil
}
func Painc(f interface{}, v ...interface{}) {
	defaultLogger.Panic(formatLog(f, v...))
}
func Fatal(f interface{}, v ...interface{}) {
	defaultLogger.Fatal(formatLog(f, v...))
}
func Emer(f interface{}, v ...interface{}) {
	defaultLogger.Emer(formatLog(f, v...))
}
func Alert(f interface{}, v ...interface{}) {
	defaultLogger.Alert(formatLog(f, v...))
}
func Crit(f interface{}, v ...interface{}) {
	defaultLogger.Crit(formatLog(f, v...))
}
func Error(f interface{}, v ...interface{}) {
	defaultLogger.Error(formatLog(f, v...))
}
func Warn(f interface{}, v ...interface{}) {
	defaultLogger.Warn(formatLog(f, v...))
}
func Info(f interface{}, v ...interface{}) {
	defaultLogger.Info(formatLog(f, v...))
}
func Debug(f interface{}, v ...interface{}) {
	defaultLogger.Debug(formatLog(f, v...))
}