Documentation ¶
Overview ¶
Package trace provides simple helpers to trace the function calls, errors or logs reference
package main import ( "log" "github.com/vardius/trace" ) func main() { log.Printf("%s\n\t%s", "Hello from:", trace.Here(trace.Lfile | trace.Lline | trace.Lfunction)) }
Example (FromParent) ¶
package main import ( "fmt" "github.com/vardius/trace" ) func main() { c := func() { fmt.Printf("%s\n%s", "Hello from:", trace.FromParent(3, trace.Lline|trace.Lfunction)) } b := func() { c() } a := func() { b() } a() }
Output: Hello from: :43 github.com/vardius/trace_test.Example_fromParent
Example (Here) ¶
package main import ( "fmt" "github.com/vardius/trace" ) func main() { c := func() { fmt.Printf("%s\n%s", "Hello from:", trace.Here(trace.Lline|trace.Lfunction)) } b := func() { c() } a := func() { b() } a() }
Output: Hello from: :12 github.com/vardius/trace_test.Example_here.func1
Example (Here_second) ¶
package main import ( "errors" "fmt" "github.com/vardius/trace" ) func main() { err := errors.New("Internal system error") fmt.Printf("%s %s\n%s", "Error:", err, trace.Here(trace.Lline|trace.Lfunction)) }
Output: Error: Internal system error :28 github.com/vardius/trace_test.Example_here_second
Index ¶
Examples ¶
Constants ¶
View Source
const ( Lfile = 1 << iota // full file name Lline // line number Lfunction // name of the function LstdFlags = Lfile | Lfunction // initial values )
Output flags
Variables ¶
This section is empty.
Functions ¶
func FromParent ¶ added in v1.0.1
FromParent returns string representation of a parent reference default flags LstdFlags
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.