Back to godoc.org
github.com/ufoot/vapor/go/vplog

package vplog

v0.0.0 (bf055c7)
Latest Go to latest
Published: Dec 6, 2019 | License: GPL3 | Module: github.com/ufoot/vapor

Overview

Package vplog contains a simple log helper which logs on both stderr and syslog.

Index

Constants

const PackageCopyright = "Copyright (C)  2015, 2016  Christian Mauduit <ufoot@ufoot.org>" // PackageCopyright set by version.sh

PackageCopyright contains a short copyright notice.

const PackageEmail = "ufoot@ufoot.org" // PackageEmail set by version.sh

PackageEmail contains a contact email for the package.

const PackageLicense = "GNU GPL v3" // PackageLicense set by version.sh

PackageLicense contains a short license information.

const PackageName = "Vapor Toolkit" // PackageName set by version.sh

PackageName contains a readable name of the package, suitable for display.

const PackageTarname = "vapor" // PackageTarname set by version.sh

PackageTarname contains a short name of the package, suitable for a filename.

const PackageURL = "https://github.com/ufoot/vapor" // PackageURL set by version.sh

PackageURL contains the address of the project homepage.

const VersionMajor = 0 // VersionMajor set by version.sh

VersionMajor is the project major version.

const VersionMinor = 4 // VersionMinor set by version.sh

VersionMinor is the project minor version.

const VersionStamp = "c6a4298" // VersionStamp set by version.sh

VersionStamp is the project stamp, possibly changes for each build.

func LogCrit

func LogCrit(v ...interface{})

LogCrit logs a critical message, no formatting. Uses the default global logging backend.

func LogCritf

func LogCritf(f string, v ...interface{})

LogCritf logs a critical message, formatting "à la" printf. Uses the default global logging backend.

func LogDebug

func LogDebug(v ...interface{})

LogDebug logs a debug message, no formatting. Uses the default global logging backend.

func LogDebugf

func LogDebugf(f string, v ...interface{})

LogDebugf logs a debug message, formatting "à la" printf. Uses the default global logging backend.

func LogErr

func LogErr(v ...interface{})

LogErr logs an error message, no formatting. Uses the default global logging backend.

func LogErrf

func LogErrf(f string, v ...interface{})

LogErrf logs an error message, formatting "à la" printf. Uses the default global logging backend.

func LogFlush

func LogFlush()

LogFlush flushes the global logging system, more precisely, flushes stderr.

func LogInfo

func LogInfo(v ...interface{})

LogInfo logs an information message, no formatting. Uses the default global logging backend.

func LogInfof

func LogInfof(f string, v ...interface{})

LogInfof logs an information message, formatting "à la" printf. Uses the default global logging backend.

func LogInit

func LogInit(program string)

LogInit initializes the log system. This is not mandatory, you might use functions such as LogWarning right away, the log file will be opened on-the-fly if needed. However, you might prefer to have the file opened at the very beginning of the program, without waiting for an artificial event. This is why this function is here. It can also be used to force a given file to be used, by default the program name "vapor" is used but it can be overridden.

func LogNotice

func LogNotice(v ...interface{})

LogNotice logs a notice message, no formatting. Uses the default global logging backend.

func LogNoticef

func LogNoticef(f string, v ...interface{})

LogNoticef logs a notice message, formatting "à la" printf. Uses the default global logging backend.

func LogSetPriority

func LogSetPriority(p Priority)

LogSetPriority sets the global, default logging level. Uses the default global logging backend.

func LogWarning

func LogWarning(v ...interface{})

LogWarning logs a warning message, no formatting. Uses the default global logging backend.

func LogWarningf

func LogWarningf(f string, v ...interface{})

LogWarningf logs a warning message, formatting "à la" printf. Uses the default global logging backend.

func LoggerCrit

func LoggerCrit(l Logger, v ...interface{})

LoggerCrit logs a message with critical level. No formatting.

func LoggerCritf

func LoggerCritf(l Logger, f string, v ...interface{})

LoggerCritf logs a message with critical level. Formatting "à la" printf.

func LoggerDebug

func LoggerDebug(l Logger, v ...interface{})

LoggerDebug logs a message with debug level. No formatting.

func LoggerDebugf

func LoggerDebugf(l Logger, f string, v ...interface{})

LoggerDebugf logs a message with debug level. Formatting "à la" printf.

func LoggerErr

func LoggerErr(l Logger, v ...interface{})

LoggerErr logs a message with error level. No formatting.

func LoggerErrf

func LoggerErrf(l Logger, f string, v ...interface{})

LoggerErrf logs a message with error level. Formatting "à la" printf.

func LoggerInfo

func LoggerInfo(l Logger, v ...interface{})

LoggerInfo logs a message with info level. No formatting.

func LoggerInfof

func LoggerInfof(l Logger, f string, v ...interface{})

LoggerInfof logs a message with info level. Formatting "à la" printf.

func LoggerNotice

func LoggerNotice(l Logger, v ...interface{})

LoggerNotice logs a message with notice level. No formatting.

func LoggerNoticef

func LoggerNoticef(l Logger, f string, v ...interface{})

LoggerNoticef logs a message with notice level. Formatting "à la" printf.

func LoggerWarning

func LoggerWarning(l Logger, v ...interface{})

LoggerWarning logs a message with warning level. No formatting.

func LoggerWarningf

func LoggerWarningf(l Logger, f string, v ...interface{})

LoggerWarningf logs a message with warning level. Formatting "à la" printf.

func PriorityString

func PriorityString(p Priority) string

PriorityString returns a readable string (English word) that corresponds to a given log priority.

type Log

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

Log is a default implementation of the Logger interface. It basically logs informations in two places, which are the console (stderr) and syslog.

func NewLog

func NewLog(program string) *Log

NewLog Constructs a new log object, note that this is called under the hood by the global shared object constructor.

func (*Log) Flush

func (l *Log) Flush()

Flush flushes all channels for which it makes sense to be flushed. This is automatically called if priority is CRIT, ERR, WARNING or NOTICE.

func (*Log) GetPriority

func (l *Log) GetPriority() Priority

GetPriority returns the priority under which message won't be displayed any more.

func (*Log) Logp

func (l *Log) Logp(p Priority, v ...interface{})

Logp logs a message on all relevant channels. EOL is added at the end, you do not need to provide it.

func (*Log) Logpf

func (l *Log) Logpf(p Priority, format string, v ...interface{})

Logpf logs a message on all relevant channels, using a printf-like syntax. EOL is added at the end, you do not need to provide it.

func (*Log) SetPriority

func (l *Log) SetPriority(p Priority)

SetPriority sets the priority above which message won't be displayed any more.

type Logger

type Logger interface {
	Logp(p Priority, v ...interface{})
	Logpf(p Priority, f string, v ...interface{})
	SetPriority(p Priority)
	GetPriority() Priority
	Flush()
}

Logger is a custom logging interface, while the package with only one implementation, the interface is technically generic, and could be implemented/used elsewhere. This is design for quick-to-write global usage, not for universality/versatility.

type Priority

type Priority int

Priority is a logging priority (AKA level), the lower the number, the higher the priority.

const (
	// PriorityCrit should be used for critical messages.
	// Inspired from /usr/include/sys/syslog.h.
	// We don't use EMERG and ALERT
	PriorityCrit Priority = iota + Priority(int(syslog.LOG_CRIT))
	// PriorityErr should be used for error messages.
	PriorityErr
	// PriorityWarning should be used for warning messages.
	PriorityWarning
	// PriorityNotice should be used for notice messages.
	PriorityNotice
	// PriorityInfo should be used for information messages.
	PriorityInfo
	// PriorityDebug should be used for debugging messages.
	PriorityDebug
)

func LogGetPriority

func LogGetPriority() Priority

LogGetPriority returns the global, default logging level. Uses the default global logging backend.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier