logger

package
v0.0.0-...-29ca9c5 Latest Latest
Warning

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

Go to latest
Published: May 19, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

The Logger of the Go Application Support provides a flexible way to log information with different levels and on different backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Criticalf

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

Criticalf logs a message at critical level.

func Debugf

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

Debugf logs a message at debug level.

func Errorf

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

Errorf logs a message at error level.

func Infof

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

Infof logs a message at info level.

func PackageVersion

func PackageVersion() version.Version

PackageVersion returns the version of the version package.

func SetLevel

func SetLevel(level LogLevel)

SetLevel switches to a new log level.

func SetLogger

func SetLogger(l Logger)

SetLogger sets a new logger.

func Warningf

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

Warningf logs a message at warning level.

Types

type GoLogger

type GoLogger struct{}

GoLogger just uses the standard go log package.

func (*GoLogger) Critical

func (gl *GoLogger) Critical(info, msg string)

Critical logs a message at critical level.

func (*GoLogger) Debug

func (gl *GoLogger) Debug(info, msg string)

Debug logs a message at debug level.

func (*GoLogger) Error

func (gl *GoLogger) Error(info, msg string)

Error logs a message at error level.

func (*GoLogger) Info

func (gl *GoLogger) Info(info, msg string)

Info logs a message at info level.

func (*GoLogger) Warning

func (gl *GoLogger) Warning(info, msg string)

Warning logs a message at warning level.

type LogLevel

type LogLevel int

LogLevel describes the chosen log level between debug and critical.

const (
	LevelDebug LogLevel = iota
	LevelInfo
	LevelWarning
	LevelError
	LevelCritical
)

Log levels to control the logging output.

func Level

func Level() LogLevel

Level returns the current log level.

type Logger

type Logger interface {
	// Debug logs a message at debug level.
	Debug(info, msg string)
	// Info logs a message at info level.
	Info(info, msg string)
	// Warning logs a message at warning level.
	Warning(info, msg string)
	// Error logs a message at error level.
	Error(info, msg string)
	// Critical logs a message at critical level.
	Critical(info, msg string)
}

Logger is the interface for different logger backends.

func NewGoLogger

func NewGoLogger() Logger

NewGoLogger returns a logger implementation using the Go log package.

func NewStandardLogger

func NewStandardLogger(out io.Writer) Logger

NewStandardLogger creates the standard logger.

func NewSysLogger

func NewSysLogger(tag string) (Logger, error)

NewGoLogger returns a logger implementation using the Go syslog package.

type StandardLogger

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

StandardLogger is a simple logger writing to the given writer. It doesn't handle the levels differently.

func (*StandardLogger) Critical

func (sl *StandardLogger) Critical(info, msg string)

Critical logs a message at critical level.

func (*StandardLogger) Debug

func (sl *StandardLogger) Debug(info, msg string)

Debug logs a message at debug level.

func (*StandardLogger) Error

func (sl *StandardLogger) Error(info, msg string)

Error logs a message at error level.

func (*StandardLogger) Info

func (sl *StandardLogger) Info(info, msg string)

Info logs a message at info level.

func (*StandardLogger) Warning

func (sl *StandardLogger) Warning(info, msg string)

Warning logs a message at warning level.

type SysLogger

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

SysLogger uses the Go syslog package as logging backend. It does not work on Windows or Plan9.

func (*SysLogger) Critical

func (sl *SysLogger) Critical(info, msg string)

Critical logs a message at critical level.

func (*SysLogger) Debug

func (sl *SysLogger) Debug(info, msg string)

Debug logs a message at debug level.

func (*SysLogger) Error

func (sl *SysLogger) Error(info, msg string)

Error logs a message at error level.

func (*SysLogger) Info

func (sl *SysLogger) Info(info, msg string)

Info logs a message at info level.

func (*SysLogger) Warning

func (sl *SysLogger) Warning(info, msg string)

Warning logs a message at warning level.

Jump to

Keyboard shortcuts

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