logger

package module
v0.0.0-...-67c9af6 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: Apache-2.0 Imports: 10 Imported by: 22

Documentation

Overview

Package logger logs messages as appropriate.

Package logger logs messages as appropriate.

Package logger logs messages as appropriate.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DeferredFatalFuncs is a slice of functions that will be called prior to os.Exit in Fatal.
	DeferredFatalFuncs []func()
)

Functions

func Close

func Close()

Close closes the logger.

func Debugf

func Debugf(format string, v ...interface{})

Debugf logs debug information.

func Errorf

func Errorf(format string, v ...interface{})

Errorf logs error information.

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf logs critical error information and exits.

func Infof

func Infof(format string, v ...interface{})

Infof logs general information.

func Init

func Init(ctx context.Context, opts LogOpts) error

Init instantiates the logger.

func Log

func Log(e LogEntry)

Log writes an entry to all outputs.

func Warningf

func Warningf(format string, v ...interface{})

Warningf logs warning information.

Types

type LogEntry

type LogEntry struct {
	Message   string            `json:"message"`
	Labels    map[string]string `json:"-"`
	CallDepth int               `json:"-"`
	Severity  Severity          `json:"-"`
	// Source will be overwritten, do not set.
	Source *logpb.LogEntrySourceLocation `json:"-"`
	// LocalTimestamp will be overwritten, do not set.
	LocalTimestamp string `json:"localTimestamp"`
}

LogEntry encapsulates a single log entry.

func (LogEntry) String

func (e LogEntry) String() string

type LogOpts

type LogOpts struct {
	Stdout      bool
	Debug       bool
	ProjectName string
	LoggerName  string
	// FormatFunction will produce the string representation of each log event.
	FormatFunction func(LogEntry) string
}

LogOpts represents options for logging.

type Severity

type Severity int

Severity is the severity level of the log event.

const (
	Debug Severity = iota
	Info
	Warning
	Error
	Critical
)

Log severity levels.

func (Severity) String

func (v Severity) String() string

Jump to

Keyboard shortcuts

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