Minor changes to probe

This commit is contained in:
Harshavardhana 2015-08-02 20:31:58 -07:00
parent 574f2aaafa
commit 65e4aede82
1 changed files with 8 additions and 2 deletions

View File

@ -72,7 +72,7 @@ type Error struct {
// at the top level. // at the top level.
func New(e error) *Error { func New(e error) *Error {
Err := Error{sync.RWMutex{}, e, GetSysInfo(), []tracePoint{}} Err := Error{sync.RWMutex{}, e, GetSysInfo(), []tracePoint{}}
return Err.Trace() return Err.trace()
} }
// Trace records the point at which it is invoked. Stack traces are important for // Trace records the point at which it is invoked. Stack traces are important for
@ -81,7 +81,13 @@ func (e *Error) Trace(fields ...string) *Error {
e.lock.Lock() e.lock.Lock()
defer e.lock.Unlock() defer e.lock.Unlock()
pc, file, line, _ := runtime.Caller(1) return e.trace(fields...)
}
// internal trace - records the point at which it is invoked. Stack traces are important for
// debugging purposes.
func (e *Error) trace(fields ...string) *Error {
pc, file, line, _ := runtime.Caller(2)
function := runtime.FuncForPC(pc).Name() function := runtime.FuncForPC(pc).Name()
_, function = filepath.Split(function) _, function = filepath.Split(function)
file = "..." + strings.TrimPrefix(file, os.Getenv("GOPATH")) // trim gopathSource from file file = "..." + strings.TrimPrefix(file, os.Getenv("GOPATH")) // trim gopathSource from file