trace

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 7 Imported by: 3

Documentation

Overview

Package trace provides a simple tracing facility for Go functions. Given the function below, program execution will be traced whenever the function is entered or exited.

func fn(p1 ptype1, p2 ptype2, ...) (r1 rtyp1, r2 rtype2, ...) {
    defer trace.Trace(0, "TRACE", p1, p2)(&r1, &r2)
    // ...
}

The trace facility is disabled unless the variable Verbose is true and the environment variable GOLIB_TRACE is set to a pattern matching one of the traced functions. A pattern is a a comma-separated list of file-style patterns containing wildcards such as * and ?.

Index

Constants

This section is empty.

Variables

View Source
var (
	Verbose = false
	Pattern = os.Getenv("GOLIB_TRACE")

	Logger = log.New(terminal.Stderr, "", log.LstdFlags)
)

Functions

func Trace

func Trace(skip int, prfx string, vals ...interface{}) func(vals ...interface{})

func Tracef

func Tracef(skip int, form string, vals ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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