log

package
v0.0.0-...-eab8366 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Convenient to use with client loggers, where we don't need fine-grained info
	// GetConnection ▶ INFO  Getting the connection
	FORMAT_SHORT = `%{color}%{shortfunc} ▶ %{level} %{color:reset} %{message}`

	// Same as FORMAT_SHORT but without the color information.
	// Appropriate for logging to files or on mobile clients.
	FORMAT_SHORT_COLORLESS = `%{shortfunc} ▶ %{level} %{message}`

	// Convenient to use with server loggers, where we need more fine-grained info and readable
	// output (includes color information, useful for console output)
	// [server][Mon 25.Sep 2017,14:11:041] Start ▶ NOTI  emmy server listening for connections on port 7007
	FORMAT_LONG = `%{color}[%{module}][%{time:Mon _2.Jan 2006,15:04:005}] %{shortfunc} ▶ %{level} %{color:reset} %{message}`

	// Same as FORMAT_LONG but without the color information (for files)
	FORMAT_LONG_COLORLESS = `[%{time:Mon _2.Jan 2006,15:04:005}] %{shortfunc} ▶ %{level} %{message}`
)

Some predefined formats for logging output

View Source
const (
	DEBUG    = "DEBUG"
	INFO     = "INFO"
	NOTICE   = "NOTICE"
	WARNING  = "WARNING"
	ERROR    = "ERROR"
	CRITICAL = "CRITICAL"
	OFF      = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileLogger

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

FileLogger outputs logs to a given file.

func NewFileLogger

func NewFileLogger(module, logFilePath, logLevel, format string) (*FileLogger, error)

func (*FileLogger) SetLevel

func (logger *FileLogger) SetLevel(levelStr string) error

SetLevel sets the log level for the given logger. In case of an invalid log level argument, it propagates the error detected by go-logging's package logging

type Logger

type Logger interface {
	// This function is our own
	SetLevel(level string) error

	// These are functions hooked on go-logging's Logger struct
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Notice(args ...interface{})
	Noticef(format string, args ...interface{})
	Warning(args ...interface{})
	Warningf(format string, args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Critical(args ...interface{})
	Criticalf(format string, args ...interface{})
}

Logger is a convenience interface that makes use of all functionality from go-logging's Logger struct. In addition, it defines Disable() and SetLevel(level) functions

type NullLogger

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

NullLogger suppresses logging output

func NewNullLogger

func NewNullLogger() *NullLogger

func (*NullLogger) SetLevel

func (logger *NullLogger) SetLevel(levelStr string) error

SetLevel sets the log level for the given logger. In case of an invalid log level argument, it propagates the error detected by go-logging's package logging

type StdoutFileLogger

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

StdoutFileLogger outputs logs both to standard output as well as to a given file.

func NewStdoutFileLogger

func NewStdoutFileLogger(module, logFilePath, logLevel, formatStdout,
	formatFile string) (*StdoutFileLogger, error)

func (*StdoutFileLogger) SetLevel

func (logger *StdoutFileLogger) SetLevel(levelStr string) error

SetLevel sets the log level for the given logger. In case of an invalid log level argument, it propagates the error detected by go-logging's package logging

type StdoutLogger

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

StdoutLogger outputs logs to standard output.

func NewStdoutLogger

func NewStdoutLogger(module, logLevel, format string) (*StdoutLogger, error)

func (*StdoutLogger) SetLevel

func (logger *StdoutLogger) SetLevel(levelStr string) error

SetLevel sets the log level for the given logger. In case of an invalid log level argument, it propagates the error detected by go-logging's package logging

Jump to

Keyboard shortcuts

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