log

package module
v0.0.0-...-89f0802 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: BSD-3-Clause Imports: 4 Imported by: 6

README

Log

Simple logging with different verbosity levels

The same API as stdlib logger has, coloured records.

go get github.com/gelfand/log

txErr := errors.New("only one reader is being allowed")
log.Errorf("Failed to begin database transaction: %v", txErr)
License

BSD 3-Clause License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(arg interface{})

Debug writes debug record.

func Debugf

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

Debugf is the same as Debug except formats string with provided arguments.

func Error

func Error(arg interface{})

Error writes error record.

func Errorf

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

Errorf is the same as Error except formats string with provided arguments.

func Fatal

func Fatal(arg interface{})

Fatal is the fatal level log method.

func Fatalf

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

Fatalf is the same as Fatal except formats string with provided arguments.

func Info

func Info(arg interface{})

Info writes info record.

func Infof

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

Infof is the same as Info except formats string with provided arguments.

func Warn

func Warn(arg interface{})

Warn writes warning record.

func Warnf

func Warnf(format string, args ...interface{})

Warnf is the same as Warn except formats string with provided arguments.

Types

type Log

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

Log is the implementation of the Logger interface.

func (*Log) Debug

func (l *Log) Debug(arg interface{})

Debug writes debug record.

func (*Log) Debugf

func (l *Log) Debugf(format string, args ...interface{})

Debugf writes a Debug record.

func (*Log) Error

func (l *Log) Error(arg interface{})

Erorr is the error level log method.

func (*Log) Errorf

func (l *Log) Errorf(format string, args ...interface{})

Erorrf is the same as Error except formats string with provided arguments.

func (*Log) Fatal

func (l *Log) Fatal(arg interface{})

Fatal is the fatal level log method.

func (*Log) Fatalf

func (l *Log) Fatalf(format string, args ...interface{})

Fatalf is the same as Fatal except formats string with provided arguments.

func (*Log) Info

func (l *Log) Info(arg interface{})

Info writes info record.

func (*Log) Infof

func (l *Log) Infof(format string, args ...interface{})

Infof is the same as Info except formats string with provided arguments.

func (*Log) Warn

func (l *Log) Warn(arg interface{})

Warn writes warning record.

func (*Log) Warnf

func (l *Log) Warnf(format string, args ...interface{})

Warnf is the same as Warn except formats string with provided arguments.

type Logger

type Logger interface {
	// Debug is the debug level log method.
	Debug(arg interface{})
	// Debugf the same as Debug except formats string with provided arguments.
	Debugf(format string, args ...interface{})
	// Info is the info level log method.
	Info(arg interface{})
	// Infof the same as Info except formats string with provided arguments.
	Infof(format string, args ...interface{})
	// Warn is the warn level log method.
	Warn(arg interface{})
	// Warnf the same as Warn except formats string with provided arguments.
	Warnf(format string, args ...interface{})
	// Error is the error level log method.
	Error(arg interface{})
	// Errorf the same as Error except formats string with provided arguments.
	Errorf(format string, args ...interface{})
	// Fatal is the fatal level log method.
	Fatal(arg interface{})
	// Fatalf the same as Fatal except formats string with provided arguments.
	Fatalf(format string, args ...interface{})
}

Logger is an interface type which represents a logger.

func New

func New(w io.Writer) Logger

New creates a new Logger with provided io.Writer.

Jump to

Keyboard shortcuts

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