log

package
v0.0.0-...-9f1a7a8 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package log provides logging utility.

It abstracts the logger from the standard log package, allowing the developer to pick the logging target, changing this to a file, or syslog, for example.

Index

Constants

This section is empty.

Variables

View Source
var DefaultTarget = new(Target)

Functions

func Debug

func Debug(v string)

Debug is a wrapper for DefaultTarget.Debug.

func Debugf

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

Debugf is a wrapper for DefaultTarget.Debugf.

func Error

func Error(v error)

Error is a wrapper for DefaultTarget.Error.

func Errorf

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

Errorf is a wrapper for DefaultTarget.Errorf.

func Fatal

func Fatal(v string)

Fatal is a wrapper for DefaultTarget.Fatal.

func Fatalf

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

Fatalf is a wrapper for DefaultTarget.Errorf.

func GetStdLogger

func GetStdLogger() *log.Logger

GetStdLogger is a wrapper for DefaultTarget.GetStdLogger.

func Init

func Init() error

func SetLogger

func SetLogger(logger Logger)

SetLogger is a wrapper for DefaultTarget.SetLogger.

func WrapError

func WrapError(err error) error

func Write

func Write(w io.Writer, content []byte) error

Types

type Logger

type Logger interface {
	Error(string)
	Errorf(string, ...interface{})
	Fatal(string)
	Fatalf(string, ...interface{})
	Debug(string)
	Debugf(string, ...interface{})
	GetStdLogger() *log.Logger
}

func NewFileLogger

func NewFileLogger(fileName string, debug bool) Logger

func NewMultiLogger

func NewMultiLogger(loggers ...Logger) Logger

func NewSyslogLogger

func NewSyslogLogger(tag string, debug bool) (Logger, error)

func NewWriterLogger

func NewWriterLogger(writer io.Writer, debug bool) Logger

type Target

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

Target is the current target for the log package.

func (*Target) Debug

func (t *Target) Debug(v string)

Debug writes the value to the Target logger.

func (*Target) Debugf

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

Debugf writes the formatted string to the Target logger.

func (*Target) Error

func (t *Target) Error(v error)

Error writes the given values to the Target logger.

func (*Target) Errorf

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

Errorf writes the formatted string to the Target logger.

func (*Target) Fatal

func (t *Target) Fatal(v string)

Fatal writes the given values to the Target logger.

func (*Target) Fatalf

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

Fatalf writes the formatted string to the Target logger.

func (*Target) GetStdLogger

func (t *Target) GetStdLogger() *log.Logger

GetStdLogger returns a standard Logger instance useful for configuring log in external packages.

func (*Target) SetLogger

func (t *Target) SetLogger(l Logger)

SetLogger defines a new logger for the current target.

See the builtin log package for more details.

Jump to

Keyboard shortcuts

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