| 
					
				 | 
			
			
				@@ -0,0 +1,148 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"fmt" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"github.com/davecgh/go-spew/spew" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"os" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"path/filepath" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"runtime" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"time" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+var level = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// TRACE level 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	TRACE = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// DEBUG level 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	DEBUG = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// INFO level 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	INFO = 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// WARNING level 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	WARNING = 3 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// ERROR level 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	ERROR = 4 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// FATAL level 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	FATAL = 5 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// DumpObj struct 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+type DumpObj struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	value []interface{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Init logger 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Init(plevel int) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	level = plevel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (d DumpObj) String() string { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return spew.Sdump(d.value...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// GoString func 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (d DumpObj) GoString() string { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return spew.Sdump(d.value...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Dump object 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Dump(v ...interface{}) interface{} { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return DumpObj{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		value: v, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Trace log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Trace(a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= TRACE { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Printf("TRACE: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprint(a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Tracef log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Tracef(format string, a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= TRACE { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Printf("TRACE: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprintf(format, a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Debug log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Debug(a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= DEBUG { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Printf("DEBUG: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprint(a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Debugf log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Debugf(format string, a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= DEBUG { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Printf("DEBUG: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprintf(format, a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Info log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Info(a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= INFO { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Printf("INFO: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprint(a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Infof log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Infof(format string, a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= INFO { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Printf("INFO: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprintf(format, a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Warning log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Warning(a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= WARNING { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Printf("WARN: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprint(a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Warningf log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Warningf(format string, a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= WARNING { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Printf("WARN: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprintf(format, a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Error log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Error(a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= ERROR { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Fprintf(os.Stderr, "ERROR: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprint(a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Errorf log 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func Errorf(format string, a ...interface{}) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if level <= ERROR { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, path, line, _ := runtime.Caller(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		_, file := filepath.Split(path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		fmt.Fprintf(os.Stderr, "ERROR: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprintf(format, a...)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |