log

package module
v0.0.0-...-39ac581 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Overview

Package log implements a simple replacement for the standard go log package. It provides 3 predefined loggers DEBUG, INFO and ERROR and supports the standard go context.Context to include context specific information in every logstatement

Index

Constants

This section is empty.

Variables

View Source
var StdDebug = New(os.Stderr, newWriteMessageFunc("DEBUG"))

StdDebug is the standard logger for debug messages

View Source
var StdError = New(os.Stderr, newWriteMessageFunc("ERROR"))

StdError is the standard logger for error messages

View Source
var StdInfo = New(os.Stderr, newWriteMessageFunc("INFO"))

StdInfo is the standard logger for info messages

View Source
var StdWarn = New(os.Stderr, newWriteMessageFunc("WARN"))

StdWarn is the standard logger for warn messages

Functions

func Debug

func Debug(ctx context.Context, v ...interface{})

Debug is equivalent to log.StdDebug.Print()

func Debugf

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

Debugf is equivalent to log.StdDebug.Printf()

func Error

func Error(ctx context.Context, v ...interface{})

Error is equivalent to log.StdError.Print()

func Errorf

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

Errorf is equivalent to log.StdError.Printf()

func Info

func Info(ctx context.Context, v ...interface{})

Info is equivalent to log.StdInfo.Print()

func Infof

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

Infof is equivalent to log.StdInfo.Printf()

func Warn

func Warn(ctx context.Context, v ...interface{})

Warn is equivalent to log.StdWarn.Print()

func Warnf

func Warnf(ctx context.Context, format string, v ...interface{})

Warnf is equivalent to log.StdWarn.Printf()

Types

type Logger

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

func New

func New(out io.Writer, writeMessage ...func(ctx context.Context, buf []byte, message string) []byte) *Logger

New creates an new Logger. The out variable determines the destination for logstatements. The writeMessage variable determines callback functions which are invoked in the given order when writing the logstatement.

func (*Logger) Print

func (l *Logger) Print(ctx context.Context, v ...interface{})

Print writes v to the log. Arguments are handled in the same manner as fmt.Print.

func (*Logger) Printf

func (l *Logger) Printf(ctx context.Context, format string, v ...interface{})

Print writes v to the log. Arguments are handled in the same manner as fmt.Printf.

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

SetOuput sets the output destination for the logger

func (*Logger) SetWriteMessage

func (l *Logger) SetWriteMessage(writeMsgFunc ...func(ctx context.Context, buf []byte, message string) []byte)

SetWriteMessage set callback functions which are invoked in the given oder when this logger writes a logstatement

Directories

Path Synopsis
Package syslog provides an io.Writer for a syslog server and WriteMessageFunctions which produce RFC5424 (https://tools.ietf.org/html/rfc5424) compliant logmessages
Package syslog provides an io.Writer for a syslog server and WriteMessageFunctions which produce RFC5424 (https://tools.ietf.org/html/rfc5424) compliant logmessages

Jump to

Keyboard shortcuts

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