Bring iodine changes into mc
This commit is contained in:
Generated
+3
-1
@@ -32,11 +32,13 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/minio/minio-go",
|
||||
"Comment": "v0.1.0",
|
||||
"Rev": "115db4940219a4cb142281d0ee216d85599bd4b9"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/minio/minio/pkg/iodine",
|
||||
"Rev": "0f58045480309d4b13fe45878f05736c3ff20e7e"
|
||||
"Comment": "release-1434511043-18-g792e6c2",
|
||||
"Rev": "792e6c2d3a0bee392abd049e70f0cad52a5f8320"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/olekukonko/ts",
|
||||
|
||||
+22
-20
@@ -22,7 +22,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -51,7 +51,7 @@ type StackEntry struct {
|
||||
Data map[string]string
|
||||
}
|
||||
|
||||
var gopath string
|
||||
var gopathSource string
|
||||
|
||||
var globalState = struct {
|
||||
sync.RWMutex
|
||||
@@ -87,10 +87,9 @@ func GetGlobalState() map[string]string {
|
||||
|
||||
// GetGlobalStateKey - get value for key from globalState struct
|
||||
func GetGlobalStateKey(k string) string {
|
||||
result, ok := globalState.m[k]
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
globalState.RLock()
|
||||
result, _ := globalState.m[k]
|
||||
globalState.RUnlock()
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -152,8 +151,8 @@ func createStackEntry() StackEntry {
|
||||
host, _ := os.Hostname()
|
||||
pc, file, line, _ := runtime.Caller(2)
|
||||
function := runtime.FuncForPC(pc).Name()
|
||||
_, function = path.Split(function)
|
||||
file = strings.TrimPrefix(file, gopath) // trim gopath from file
|
||||
_, function = filepath.Split(function)
|
||||
file = strings.TrimPrefix(file, gopathSource) // trim gopathSource from file
|
||||
|
||||
data := GetGlobalState()
|
||||
for k, v := range getSystemData() {
|
||||
@@ -191,14 +190,15 @@ func getSystemData() map[string]string {
|
||||
}
|
||||
|
||||
// Annotate an error with a stack entry and returns itself
|
||||
//func (err *WrappedError) Annotate(info map[string]string) *WrappedError {
|
||||
// entry := createStackEntry()
|
||||
// for k, v := range info {
|
||||
// entry.Data[k] = v
|
||||
// }
|
||||
// err.Stack = append(err.Stack, entry)
|
||||
// return err
|
||||
//}
|
||||
//
|
||||
// func (err *WrappedError) Annotate(info map[string]string) *WrappedError {
|
||||
// entry := createStackEntry()
|
||||
// for k, v := range info {
|
||||
// entry.Data[k] = v
|
||||
// }
|
||||
// err.Stack = append(err.Stack, entry)
|
||||
// return err
|
||||
// }
|
||||
|
||||
// EmitJSON writes JSON output for the error
|
||||
func (err Error) EmitJSON() ([]byte, error) {
|
||||
@@ -223,8 +223,10 @@ func (err Error) Error() string {
|
||||
|
||||
func init() {
|
||||
_, iodineFile, _, _ := runtime.Caller(0)
|
||||
iodineFile = path.Dir(iodineFile) // trim iodine.go
|
||||
iodineFile = path.Dir(iodineFile) // trim iodine
|
||||
iodineFile = path.Dir(iodineFile) // trim minio
|
||||
gopath = path.Dir(iodineFile) + "/" // trim github.com
|
||||
iodineFile = filepath.Dir(iodineFile) // trim iodine.go
|
||||
iodineFile = filepath.Dir(iodineFile) // trim iodine
|
||||
iodineFile = filepath.Dir(iodineFile) // trim pkg
|
||||
iodineFile = filepath.Dir(iodineFile) // trim minio
|
||||
iodineFile = filepath.Dir(iodineFile) // trim minio
|
||||
gopathSource = filepath.Dir(iodineFile) + "/" // trim github.com
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user