trace

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2019 License: MIT Imports: 4 Imported by: 4

README

Vardius - trace

Build Status Go Report Card codecov license

trace - simple helper to trace the function calls, errors or logs reference

ABOUT

Contributors:

Want to contribute ? Feel free to send pull requests!

Have problems, bugs, feature ideas? We are using the github issue tracker to manage them.

HOW TO USE

  1. GoDoc
  2. Examples

Basic example

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))
}

License

This package is released under the MIT license. See the complete license in the package:

LICENSE

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

func FromParent(calldepth int, flags int) string

FromParent returns string representation of a parent reference default flags LstdFlags

func Here

func Here(flags int) string

Here returns string representation of a reference default flags LstdFlags

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL