|
@@ -6,6 +6,7 @@ import (
|
|
|
"os"
|
|
|
"path/filepath"
|
|
|
"runtime"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -71,6 +72,19 @@ func dump(a ...interface{}) []interface{} {
|
|
|
|
|
|
func Trace(a ...interface{}) {
|
|
|
if level <= TRACE {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 1)
|
|
|
+ _, file := filepath.Split(path)
|
|
|
+ fmt.Fprintf(os.Stderr, "TRACE: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprint(dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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(dump(a...)...))
|
|
@@ -80,6 +94,19 @@ func Trace(a ...interface{}) {
|
|
|
|
|
|
func Tracef(format string, a ...interface{}) {
|
|
|
if level <= TRACE {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 1)
|
|
|
+ _, file := filepath.Split(path)
|
|
|
+ fmt.Fprintf(os.Stderr, "TRACE: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprintf(format, dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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, dump(a...)...))
|
|
@@ -89,6 +116,19 @@ func Tracef(format string, a ...interface{}) {
|
|
|
|
|
|
func Debug(a ...interface{}) {
|
|
|
if level <= DEBUG {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 1)
|
|
|
+ _, file := filepath.Split(path)
|
|
|
+ fmt.Fprintf(os.Stderr, "DEBUG: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprint(dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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(dump(a...)...))
|
|
@@ -98,6 +138,19 @@ func Debug(a ...interface{}) {
|
|
|
|
|
|
func Debugf(format string, a ...interface{}) {
|
|
|
if level <= DEBUG {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 1)
|
|
|
+ _, file := filepath.Split(path)
|
|
|
+ fmt.Fprintf(os.Stderr, "DEBUG: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprintf(format, dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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, dump(a...)...))
|
|
@@ -107,6 +160,19 @@ func Debugf(format string, a ...interface{}) {
|
|
|
|
|
|
func Info(a ...interface{}) {
|
|
|
if level <= INFO {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 1)
|
|
|
+ _, file := filepath.Split(path)
|
|
|
+ fmt.Fprintf(os.Stderr, "INFO: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprint(dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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(dump(a...)...))
|
|
@@ -116,6 +182,19 @@ func Info(a ...interface{}) {
|
|
|
|
|
|
func Infof(format string, a ...interface{}) {
|
|
|
if level <= INFO {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 1)
|
|
|
+ _, file := filepath.Split(path)
|
|
|
+ fmt.Fprintf(os.Stderr, "INFO: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprintf(format, dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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, dump(a...)...))
|
|
@@ -125,6 +204,19 @@ func Infof(format string, a ...interface{}) {
|
|
|
|
|
|
func Warning(a ...interface{}) {
|
|
|
if level <= WARNING {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 1)
|
|
|
+ _, file := filepath.Split(path)
|
|
|
+ fmt.Fprintf(os.Stderr, "WARN: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprint(dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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(dump(a...)...))
|
|
@@ -134,6 +226,19 @@ func Warning(a ...interface{}) {
|
|
|
|
|
|
func Warningf(format string, a ...interface{}) {
|
|
|
if level <= WARNING {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 1)
|
|
|
+ _, file := filepath.Split(path)
|
|
|
+ fmt.Fprintf(os.Stderr, "WARN: %s %v:%v: %s\n", time.Now().Format("01:04:05.000"), file, line, fmt.Sprintf(format, dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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, dump(a...)...))
|
|
@@ -143,6 +248,19 @@ func Warningf(format string, a ...interface{}) {
|
|
|
|
|
|
func Error(a ...interface{}) {
|
|
|
if level <= ERROR {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 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(dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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(dump(a...)...))
|
|
@@ -152,26 +270,21 @@ func Error(a ...interface{}) {
|
|
|
|
|
|
func Errorf(format string, a ...interface{}) {
|
|
|
if level <= ERROR {
|
|
|
+ for i := 1; i > 0 && i < 100; i++ {
|
|
|
+ _, path, _, _ := runtime.Caller(i)
|
|
|
+ if path != "" {
|
|
|
+ if strings.HasSuffix(path, "/libexec/src/runtime/panic.go") {
|
|
|
+ _, path, line, _ := runtime.Caller(i + 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, dump(a...)...))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ i = -999
|
|
|
+ }
|
|
|
+ }
|
|
|
_, 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, dump(a...)...))
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-func RError(a ...interface{}) {
|
|
|
- if level <= ERROR {
|
|
|
- _, path, line, _ := runtime.Caller(2)
|
|
|
- _, 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(dump(a...)...))
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-func RErrorf(format string, a ...interface{}) {
|
|
|
- if level <= ERROR {
|
|
|
- _, path, line, _ := runtime.Caller(2)
|
|
|
- _, 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, dump(a...)...))
|
|
|
- }
|
|
|
-}
|