log

package
v0.0.0-...-70e5bc8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 6 Imported by: 68

Documentation

Overview

Package log exports logging primitives that log to stderr and also to Google Cloud Logging.

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug = &logger{DebugLevel}
	Info  = &logger{InfoLevel}
	Error = &logger{ErrorLevel}
)

The set of default loggers for each log level.

Functions

func At

func At(level string) bool

At returns whether the level will be logged currently.

func Fatal

func Fatal(v ...interface{})

Fatal writes a message to the log and aborts.

func Fatalf

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

Fatalf writes a formatted message to the log and aborts.

func Flush

func Flush()

Flush flushes the external logger, if any.

func GetLevel

func GetLevel() string

GetLevel returns the current logging level.

func NewStdLogger

func NewStdLogger(l Logger) *log.Logger

NewStdLogger creates a *log.Logger ("log" is from the Go standard library) that forwards messages to the provided upspin logger using a logBridge. The standard logger is configured with log.Lshortfile, this log line format which is parsed to extract the log message (skipping the filename, line number) to forward it to the provided upspin logger.

func Print

func Print(v ...interface{})

Print writes a message to the log.

func Printf

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

Printf writes a formatted message to the log.

func Println

func Println(v ...interface{})

Println writes a line to the log.

func Register

func Register(e ExternalLogger)

Register connects an ExternalLogger to the default logger. This may only be called once.

func SetLevel

func SetLevel(level string) error

SetLevel sets the current level of logging.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the default loggers to write to w. If w is nil, the default loggers are disabled.

Types

type ExternalLogger

type ExternalLogger interface {
	Log(Level, string)
	Flush()
}

ExternalLogger describes a service that processes logs.

type Level

type Level int

Level represents the level of logging.

const (
	DebugLevel Level = iota
	InfoLevel
	ErrorLevel
	DisabledLevel
)

Different levels of logging.

type Logger

type Logger interface {
	// Printf writes a formated message to the log.
	Printf(format string, v ...interface{})

	// Print writes a message to the log.
	Print(v ...interface{})

	// Println writes a line to the log.
	Println(v ...interface{})

	// Fatal writes a message to the log and aborts.
	Fatal(v ...interface{})

	// Fatalf writes a formated message to the log and aborts.
	Fatalf(format string, v ...interface{})
}

Logger is the interface for logging messages.

Jump to

Keyboard shortcuts

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