logp

package
v6.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultKeepFiles = 7
View Source
const DefaultPermissions = 0600
View Source
const DefaultRotateEveryBytes = 10 * 1024 * 1024
View Source
const RotatorMaxFiles = 1024

Variables

This section is empty.

Functions

func Critical

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

func Debug

func Debug(selector string, format string, v ...interface{})

func Err

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

func HandleFlags

func HandleFlags(name string) error

func HasSelector

func HasSelector(selector string) bool

func Info

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

func Init

func Init(name string, start time.Time, config *Logging) error

Init combines the configuration from config with the command line flags to initialize the Logging systems. After calling this function, standard output is always enabled. You can make it respect the command line flag with a later SetStderr call.

func IsDebug

func IsDebug(selector string) bool

func LogInit

func LogInit(level Priority, prefix string, toSyslog bool, toStderr bool, debugSelectors []string)

TODO: remove toSyslog and toStderr from the init function

func LogTotalExpvars

func LogTotalExpvars(cfg *Logging)

LogTotalExpvars logs all registered expvar metrics.

func MakeDebug

func MakeDebug(selector string) func(string, ...interface{})

func Recover

func Recover(msg string)

func SetStderr

func SetStderr()

func SetToFile

func SetToFile(toFile bool, rotator *FileRotator) error

func SetToStderr

func SetToStderr(toStderr bool, prefix string)

func SetToSyslog

func SetToSyslog(toSyslog bool, prefix string)

func WTF

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

WTF prints the message at CRIT level and panics immediately with the same message

func Warn

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

Types

type FileRotator

type FileRotator struct {
	Path             string
	Name             string
	RotateEveryBytes *uint64
	KeepFiles        *int
	Permissions      *uint32
	// contains filtered or unexported fields
}

func (*FileRotator) CheckIfConfigSane

func (rotator *FileRotator) CheckIfConfigSane() error

func (*FileRotator) CreateDirectory

func (rotator *FileRotator) CreateDirectory() error

func (*FileRotator) FileExists

func (rotator *FileRotator) FileExists(fileNo int) bool

func (*FileRotator) FilePath

func (rotator *FileRotator) FilePath(fileNo int) string

func (*FileRotator) Rotate

func (rotator *FileRotator) Rotate() error

func (*FileRotator) WriteLine

func (rotator *FileRotator) WriteLine(line []byte) error

type Logger

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

Logger provides a logging type using the global logp functionality. The Logger should be used to use with libraries havng a configurable logging functionality.

func NewLogger

func NewLogger(selector string) *Logger

NewLogger creates a new Logger instance with custom debug selector.

func (*Logger) Debug

func (l *Logger) Debug(vs ...interface{})

func (*Logger) Debugf

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

func (*Logger) Err

func (*Logger) Err(vs ...interface{})

func (*Logger) Errf

func (*Logger) Errf(format string, v ...interface{})

func (*Logger) Info

func (*Logger) Info(vs ...interface{})

func (*Logger) Infof

func (*Logger) Infof(format string, v ...interface{})

type Logging

type Logging struct {
	Selectors []string
	Files     *FileRotator
	ToSyslog  *bool `config:"to_syslog"`
	ToFiles   *bool `config:"to_files"`
	JSON      bool  `config:"json"`
	Level     string
	Metrics   LoggingMetricsConfig `config:"metrics"`
}

type LoggingMetricsConfig

type LoggingMetricsConfig struct {
	Enabled *bool          `config:"enabled"`
	Period  *time.Duration `config:"period" validate:"nonzero,min=0s"`
}

type Priority

type Priority int
const (
	// From /usr/include/sys/syslog.h.
	// These are the same on Linux, BSD, and OS X.
	LOG_EMERG Priority = iota
	LOG_ALERT
	LOG_CRIT
	LOG_ERR
	LOG_WARNING
	LOG_NOTICE
	LOG_INFO
	LOG_DEBUG
)

Jump to

Keyboard shortcuts

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