log

package
v0.1.0-beta-007 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefault

func SetDefault(l *Logger)

SetDefault sets the default Logger.

Types

type Entry

type Entry struct {
	Severity Severity
	Message  string
	Error    error
	Data     interface{}
	// contains filtered or unexported fields
}

Entry represents a log entry.

func (*Entry) Add

func (e *Entry) Add(data interface{}) *Entry

Add appends a data object to the long entry.

func (*Entry) Err

func (e *Entry) Err(err error) *Entry

Err appends an error object to the log entry.

func (*Entry) Write

func (e *Entry) Write(msg string)

Write emits the log entry with the given message to the underlying sink.

func (*Entry) WriteFmt

func (e *Entry) WriteFmt(format string, args ...interface{})

WriteFmt emits the log entry with the given message to the underlying sink.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger writes application log entries.

func Get

func Get() *Logger

Get returns the default singleton Logger.

func NewLogger

func NewLogger(sink Sink) *Logger

NewLogger creates a new Logger.

func (*Logger) Alert

func (l *Logger) Alert() *Entry

Alert creates an alert log entry.

func (*Logger) Critical

func (l *Logger) Critical() *Entry

Critical creates a critical log entry.

func (*Logger) Debug

func (l *Logger) Debug() *Entry

Debug creates a debug log entry.

func (*Logger) Emergency

func (l *Logger) Emergency() *Entry

Emergency creates an emergency log entry.

func (*Logger) Error

func (l *Logger) Error() *Entry

Error creates an error log entry.

func (*Logger) Info

func (l *Logger) Info() *Entry

Info creates an info log entry.

func (*Logger) Notice

func (l *Logger) Notice() *Entry

Notice creates a notice log entry.

func (*Logger) Severity

func (l *Logger) Severity(severity Severity) *Entry

Severity creates a debug log entry.

func (*Logger) Sink

func (l *Logger) Sink() Sink

Sink returns the underlying sink.

func (*Logger) Warning

func (l *Logger) Warning() *Entry

Warning creates a warning log entry.

type Severity

type Severity int

Severity of the log message.

const (
	// Default means that the log entry has no assigned severity level.
	Default Severity = iota * 100
	// Debug or trace information.
	Debug
	// Info events are routine information, such as ongoing status or performance.
	Info
	// Notice are normal but significant events, such as start up, shut down, or a configuration change.
	Notice
	// Warning events might cause problems.
	Warning
	// Error events are likely to cause problems.
	Error
	// Critical events cause more severe problems or outages.
	Critical
	// Alert events mean that a person must take an action immediately.
	Alert
	// Emergency means that one or more systems are unusable.
	Emergency
)

func ParseSeverity

func ParseSeverity(value string) Severity

ParseSeverity parses a string value into a Severity.

func (Severity) Short

func (s Severity) Short() string

Short returns a 3 letter acronym for the severity level.

func (Severity) String

func (s Severity) String() string

type Sink

type Sink interface {
	AddHTTPRequest(req *http.Request) Sink
	AddRequestID(requestID string) Sink
	WriteLog(entry *Entry)
}

Sink writes application logs to a specified medium.

Jump to

Keyboard shortcuts

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