logger

package module
v0.0.0-...-c221c11 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2018 License: Apache-2.0 Imports: 1 Imported by: 9

README

logger.Interface (alpha)

An interface compatible with built-in type log.Logger. Use this interface instead of a concrete type like log.Logger when you need logging. This will allow you to swap implementatations when needed.

type Interface interface {
	SetOutput(w io.Writer)
	Output(calldepth int, s string) error
	Printf(format string, v ...interface{})
	Print(v ...interface{})
	Println(v ...interface{})
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Fatalln(v ...interface{})
	Panic(v ...interface{})
	Panicf(format string, v ...interface{})
	Panicln(v ...interface{})
	Flags() int
	SetFlags(flag int)
	Prefix() string
	SetPrefix(prefix string)
}

Compatible APIs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// SetOutput sets the output destination for the logger.
	SetOutput(w io.Writer)

	// Output writes the output for a logging event. The string s contains
	// the text to print after the prefix specified by the flags of the
	// Logger. A newline is appended if the last character of s is not
	// already a newline. Calldepth is used to recover the PC and is
	// provided for generality, although at the moment on all pre-defined
	// paths it will be 2.
	Output(calldepth int, s string) error
	// Printf calls l.Output to print to the logger.
	// Arguments are handled in the manner of fmt.Printf.
	Printf(format string, v ...interface{})
	// Print calls l.Output to print to the logger.
	// Arguments are handled in the manner of fmt.Print.
	Print(v ...interface{})
	// Println calls l.Output to print to the logger.
	// Arguments are handled in the manner of fmt.Println.
	Println(v ...interface{})
	// Fatal is equivalent to l.Print() followed by a call to os.Exit(1).
	Fatal(v ...interface{})
	// Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).
	Fatalf(format string, v ...interface{})
	// Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).
	Fatalln(v ...interface{})
	// Panic is equivalent to l.Print() followed by a call to panic().
	Panic(v ...interface{})
	// Panicf is equivalent to l.Printf() followed by a call to panic().
	Panicf(format string, v ...interface{})
	// Panicln is equivalent to l.Println() followed by a call to panic().
	Panicln(v ...interface{})
	// Flags returns the output flags for the logger.
	Flags() int
	// SetFlags sets the output flags for the logger.
	SetFlags(flag int)
	// Prefix returns the output prefix for the logger.
	Prefix() string
	// SetPrefix sets the output prefix for the logger.
	SetPrefix(prefix string)
}

Interface provides an interface with a method set compatible with the Go log.Logger type. It can be used to implement loggers using the with similar method signatures.

Jump to

Keyboard shortcuts

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