logging

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: BSD-3-Clause Imports: 0 Imported by: 15

Documentation

Overview

Package loging defines an interface for logging modeled on Google's glog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorLog

type ErrorLog interface {
	// Error logs to the ERROR and INFO logs.
	// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
	Error(args ...interface{})

	// ErrorDepth acts as Error but uses depth to determine which call frame to log.
	// A depth of 0 is equivalent to calling Error.
	ErrorDepth(depth int, args ...interface{})

	// Errorf logs to the ERROR and INFO logs.
	// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
	Errorf(format string, args ...interface{})
}

type FatalLog

type FatalLog interface {
	// Fatal logs to the FATAL, ERROR and INFO logs,
	// including a stack trace of all running goroutines, then calls os.Exit(255).
	// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
	Fatal(args ...interface{})

	// FatalDepth acts as Fatal but uses depth to determine which call frame to log.
	// A depth of 0 is equivalent to calling Fatal.
	FatalDepth(depth int, args ...interface{})

	// Fatalf logs to the FATAL, ERROR and INFO logs,
	// including a stack trace of all running goroutines, then calls os.Exit(255).
	// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
	Fatalf(format string, args ...interface{})
}

type InfoLog

type InfoLog interface {
	// Info logs to the INFO log.
	// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
	Info(args ...interface{})

	// Infoln logs to the INFO log.
	// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
	Infof(format string, args ...interface{})

	// InfoDepth acts as Info but uses depth to determine which call frame to log.
	// A depth of 0 is equivalent to calling Info.
	InfoDepth(depth int, args ...interface{})

	// InfoStack logs the current goroutine's stack if the all parameter
	// is false, or the stacks of all goroutines if it's true.
	InfoStack(all bool)
}

type Logger

type Logger interface {
	InfoLog
	ErrorLog
	FatalLog
	PanicLog
	Verbosity
	// Flush flushes all pending log I/O.
	FlushLog()
}
var Discard Logger = &discard{}

Discard is an implementation of Logger that discards all input, the equivalent of /dev/null. Fatal*, Panic* and all management methods are also no-ops.

type PanicLog

type PanicLog interface {
	// Panic is equivalent to Error() followed by a call to panic().
	Panic(args ...interface{})

	// PanicDepth acts as Panic but uses depth to determine which call frame to log.
	// A depth of 0 is equivalent to calling Panic.
	PanicDepth(depth int, args ...interface{})

	// Panicf is equivalent to Errorf() followed by a call to panic().
	Panicf(format string, args ...interface{})
}

type Verbosity

type Verbosity interface {
	// V returns true if the configured logging level is greater than or equal to its parameter
	V(level int) bool

	// VDepth acts as V but uses depth to determine which call frame to test against.
	VDepth(depth int, level int) bool

	// VI is like V, except that it returns an anonymous interface that with the
	// same method set as InfoLog that will either log (if level >= the configured level)
	// or discard its parameters. This allows for logger.VI(2).Info style usage. An
	// anonymous interface is used to allow for implementations that don't need to
	// depend on this package.
	VI(level int) interface {
		// Info logs to the INFO log.
		// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
		Info(args ...interface{})

		// Infoln logs to the INFO log.
		// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
		Infof(format string, args ...interface{})

		// InfoDepth acts as Info but uses depth to determine which call frame to log.
		// A depth of 0 is equivalent to calling Info.
		InfoDepth(depth int, args ...interface{})

		// InfoStack logs the current goroutine's stack if the all parameter
		// is false, or the stacks of all goroutines if it's true.
		InfoStack(all bool)
	}

	// VIDepth acts as VI but uses depth to determine which call frame to test against.
	VIDepth(depth int, level int) interface {
		// Info logs to the INFO log.
		// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
		Info(args ...interface{})

		// Infoln logs to the INFO log.
		// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
		Infof(format string, args ...interface{})

		// InfoDepth acts as Info but uses depth to determine which call frame to log.
		// A depth of 0 is equivalent to calling Info.
		InfoDepth(depth int, args ...interface{})

		// InfoStack logs the current goroutine's stack if the all parameter
		// is false, or the stacks of all goroutines if it's true.
		InfoStack(all bool)
	}
}

Jump to

Keyboard shortcuts

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