logging

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Overview

Package logging contains logging related functions used by multiple packages

Index

Constants

View Source
const (
	// Me is the setting for the function that called MyCaller.
	Me = 3
	// MyCaller is the setting for the function that called the function calling MyCaller.
	MyCaller = 4
	// MyCallersCaller is the setting for the function that called the function that called the function calling MyCaller.
	MyCallersCaller = 5
	// MyCallersCallersCaller is the setting for the function that called the function that called the function that called the function calling MyCaller.
	MyCallersCallersCaller = 6
)

Variables

View Source
var TraceLevel = four // nolint:gochecknoglobals //ok

Functions

func CallerStr

func CallerStr(skip uint) string

CallerStr returns the caller's function, source file and line number as a string.

func CallerText

func CallerText(skip uint) string

CallerText generates a string containing caller function, source and line.

func GetFunctionAndSource

func GetFunctionAndSource(skip uint) (result []interface{})

GetFunctionAndSource gets function name and source line for logging.

func GetObjKindNamespaceName

func GetObjKindNamespaceName(obj k8sruntime.Object) (result []interface{})

GetObjKindNamespaceName gets object kind namespace and name for logging.

func GetObjNamespaceName

func GetObjNamespaceName(obj k8sruntime.Object) (result []interface{})

GetObjNamespaceName gets object namespace and name for logging.

func LogJSON

func LogJSON(data interface{}) string

LogJSON is used log an item in JSON format.

func NewLogger

func NewLogger(name string, logOpts *zap.Options) logr.Logger

NewLogger returns a logger configured the timestamps format is ISO8601.

func TraceCall

func TraceCall(log logr.Logger)

TraceCall traces calls and exit for functions.

func TraceExit

func TraceExit(log logr.Logger)

TraceExit traces calls and exit for functions.

Types

type CallerInfo

type CallerInfo struct {
	FunctionName string
	SourceFile   string
	SourceLine   int
}

CallerInfo hold the function name and source file/line from which a call was made.

func Callers

func Callers(levels uint, short bool) ([]CallerInfo, error)

Callers returns an array of strings containing the function name, source filename and line number for the caller of this function and its caller moving up the stack for as many levels as are available or the number of levels specified by the levels parameter. Set the short parameter to true to only return final element of Function and source file name.

func GetCaller

func GetCaller(skip uint, short bool) CallerInfo

GetCaller returns the caller of GetCaller 'skip' levels back. Set the short parameter to true to only return final element of Function and source file name.

Jump to

Keyboard shortcuts

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