apilog

package
Version: v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: BSD-3-Clause Imports: 8 Imported by: 3

Documentation

Overview

Package apilog provides functions to be used in conjunction with logcop. In particular, logcop will inject calls to these functions as the first statement in methods that implement the v23 API. The output can be controlled by vlog verbosity or vtrace. --vmodule=apilog=<level> can be used to globally control logging, and --vmodule=module=<level> can also be used to control logging on a per-file basis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallerName added in v0.1.8

func CallerName() string

CallerName returns the name of the calling function.

func LogCallf

func LogCallf(ctx *context.T, callerName, format string, v ...interface{}) func(*context.T, string, ...interface{})

LogCallf logs that its caller has been called given the arguments passed to it. It returns a function that is to be called when the caller returns, logging the caller’s return along with the arguments it is provided with which represent the named returns values from the function. It is primarily intended to be automotically added and removed using some form of annotation tool. If used manually, the apilog.CallerName function can be used to obtain the function name and file location. Generated calls to LogCallf will generally insert the actual value for callerName to avoid the run time overhead of obtaining them. LogCallf will also log an invocation identifier automatically.

The canonical way to use LogCallf is as follows:

func Function(ctx *context.T, a Type1, b Type2) ReturnType {
    defer apilog.LogCallf(ctx, "<package>.<function>", "%v, %v", a, b)(ctx)
    // ... function body ...
    return retVal
}

In order for return values to be logged they must be named.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

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