trace

package
v21.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package trace traces function calls and steps in-between.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result marks an argument of Tracer.Call as a result of that function. It is only logged when exiting from the function but not when entering it.

type Tracer

type Tracer struct {
	Tracing bool
	Out     io.Writer
	// contains filtered or unexported fields
}

Tracer produces a hierarchical structure of log events.

func (*Tracer) Call

func (t *Tracer) Call(args ...interface{}) func()

Call records a function call in the tracing log, both when entering and when leaving the function.

Usage:

 if trace.Tracing {
     defer trace.Call(arg1, arg2, trace.Result(result1), trace.Result(result2))()
}

func (*Tracer) Call0

func (t *Tracer) Call0() func()

Call0 is used to trace a no-arguments function call.

Usage:

if trace.Tracing {
    defer trace.Call0()()
}

func (*Tracer) Call1

func (t *Tracer) Call1(arg1 string) func()

Call1 is used to trace a function call with a single string argument.

Usage:

if trace.Tracing {
    defer trace.Call1(str1)()
}

func (*Tracer) Call2

func (t *Tracer) Call2(arg1, arg2 string) func()

Call2 is used to trace a function call with 2 string arguments.

Usage:

if trace.Tracing {
    defer trace.Call2(str1, str2)()
}

func (*Tracer) Result

func (t *Tracer) Result(rv interface{}) Result

Result marks an argument as a result and is only logged when the function returns.

Usage: defer trace.Call(arg1, arg2, tracing.Result(&result1), tracing.Result(&result2))()

func (*Tracer) Step1

func (t *Tracer) Step1(format string, arg0 string)

func (*Tracer) Step2

func (t *Tracer) Step2(format string, arg0, arg1 string)

func (*Tracer) Stepf

func (t *Tracer) Stepf(format string, args ...interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳