Categorygithub.com/rubyist/tracerx
modulepackage
0.0.0-20170927163412-787959303086
Repository: https://github.com/rubyist/tracerx.git
Documentation: pkg.go.dev

# README

tracerx

Tracerx is a simple tracing package that logs messages depending on environment variables. It is very much inspired by git's GIT_TRACE mechanism.

GoDoc

Installation

  go get github.com/rubyist/tracerx

Example

tracerx.DefaultKey = "FOO"
tracerx.Printf("send message")

tracerx.PrintfKey("BAR", "do a thing")

t := time.Now()
// Do some stuff
tracerx.PerformanceSince("BAR", "command x", t)

This example will send tracing output based on the environment variables FOO_TRACE and BAR_TRACE.

The values control where the tracing is output as follows:

unset, 0, or "false":   no output
1, 2:                   stderr
absolute path:          output will be written to the file
3 - 10:                 output will be written to that file descriptor

If an associated BAR_TRACE_PERFORMANCE is set to 1 or "true", the PerformanceSince line will output timing information.

Keys can also be disabled. See the GoDoc for full API documentation.

Bugs, Issues, Feedback

Right here on GitHub: https://github.com/rubyist/tracerx

# Functions

Disable will disable tracing for the given key, regardless of the environment variable.
Enable will enable tracing for the given key, regardless of the environment variable.
PerformanceSince writes out the time since the given time, if tracing for the default key is enabled and the performance key is set.
PerformanceSince writes out the time since the given time, if tracing for the given key is enabled and the performance key is set.
Printf writes a trace message for the DefaultKey.
PrintfKey writes a trace message for the given key.

# Variables

No description provided by the author
No description provided by the author