logging

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package logging implements and presents various loggers under a unified interface, making them completely swappable.

These particular loggers (logging.Logger) available are:

NullLogger
StdLogger
FileLogger
SystemDLogger (Linux only)
SyslogLogger (Linux only)
WinLogger (Windows only)

There is a seventh type of logging.Logger, MultiLogger, that allows for multiple loggers to be written to with a single call. As you may have guessed, NullLogger doesn't actually log anything but is fully "functional" as a logging.Logger.

Note that for some Loggers, the prefix may be modified - "literal" loggers (StdLogger and FileLogger) will append a space to the end of the prefix. If this is undesired (unlikely), you will need to modify (Logger).Prefix and run (Logger).Logger.SetPrefix(yourPrefixHere) for the respective logger.

Every logging.Logger type has the following methods that correspond to certain "levels".

Alert(s string, v ...interface{}) (err error)
Crit(s string, v ...interface{}) (err error)
Debug(s string, v ...interface{}) (err error)
Emerg(s string, v ...interface{}) (err error)
Err(s string, v ...interface{}) (err error)
Info(s string, v ...interface{}) (err error)
Notice(s string, v ...interface{}) (err error)
Warning(s string, v ...interface{}) (err error)

Not all loggers implement the concept of levels, so approximations are made when/where possible.

In each of the above methods, s is the message that is optionally in a fmt.Sprintf-compatible format. If it is, the values to fmt.Sprintf can be passed as v.

Note that in the case of a MultiLogger, err (if not nil) will be a (r00t2.io/goutils/)multierr.MultiError.

logging.Logger types also have the following methods:

DoDebug(d bool) (err error)
GetDebug() (d bool)
SetPrefix(p string) (err error)
GetPrefix() (p string, err error)
Setup() (err error)
Shutdown() (err error)

In some cases, Logger.Setup and Logger.Shutdown are no-ops. In other cases, they perform necessary initialization/cleanup and closing of the logger. It is recommended to *always* run Setup and Shutdown before and after using, respectively, regardless of the actual logging.Logger type.

Index

Constants

View Source
const (
	// LogUndefined indicates an undefined Logger type.
	LogUndefined bitmask.MaskBit = 1 << iota
	// LogJournald flags a SystemDLogger Logger type.
	LogJournald
	// LogSyslog flags a SyslogLogger Logger type.
	LogSyslog
	// LogFile flags a FileLogger Logger type.
	LogFile
	// LogStdout flags a StdLogger Logger type.
	LogStdout
)

Flags for logger configuration. These are used internally.

Variables

View Source
var (
	// ErrExistingLogger indicates that the user attempted to add a Logger to a MultiLogger using an already-existing identifier.
	ErrExistingLogger error = errors.New("a Logger with that identifier already exists; please remove it first")
	/*
		ErrInvalidFile indicates that the user attempted to add a FileLogger to a MultiLogger but the file doesn't exist,
		exists with too restrictive perms to write/append to, and/or could not be created.
	*/
	ErrInvalidFile error = errors.New("a FileLogger was requested but the file does not exist and cannot be created")
	// ErrNoEntry indicates that the user attempted to MultiLogger.RemoveLogger a Logger but one by that identifier does not exist.
	ErrNoEntry error = errors.New("the Logger specified to be removed does not exist")
)
View Source
var (
	// ErrNoSysD indicates that the user attempted to add a SystemDLogger to a MultiLogger but systemd is unavailable.
	ErrNoSysD error = errors.New("a systemd (journald) Logger was requested but systemd is unavailable on this system")
	// ErrNoSyslog indicates that the user attempted to add a SyslogLogger to a MultiLogger but syslog's logger device is unavailable.
	ErrNoSyslog error = errors.New("a Syslog Logger was requested but Syslog is unavailable on this system")
	/*
		ErrInvalidDevLog indicates that the user attempted to add a SyslogLogger to a MultiLogger but
		the Syslog char device file is... not actually a char device file.
	*/
	ErrInvalidDevLog error = errors.New(fmt.Sprintf("a Syslog Logger was requested but %v is not a valid logger handle", devlog))
)

Functions

This section is empty.

Types

type FileLogger

type FileLogger struct {
	// StdLogger is used for the log formation and handling. See StdLogger for more details.
	StdLogger
	// Path is the path to the logfile.
	Path string
	// contains filtered or unexported fields
}

FileLogger uses a StdLogger with a file handle writer to write to the file given at Path.

NOTE: If you wish to change the FileLogger.StdLogger.LogFlags, do *not* run FileLogger.StdLogger.Setup after doing so as this will instead create a logger detached from the file handler. Instead, be sure to call FileLogger.Setup. (Alternatively, run FileLogger.Shutdown and replace your logger with a new FileLogger.)

func (*FileLogger) Alert

func (l *FileLogger) Alert(s string, v ...interface{}) (err error)

Alert writes an ALERT-level message to this FileLogger.

func (*FileLogger) Crit

func (l *FileLogger) Crit(s string, v ...interface{}) (err error)

Crit writes an CRITICAL-level message to this FileLogger.

func (*FileLogger) Debug

func (l *FileLogger) Debug(s string, v ...interface{}) (err error)

Debug writes a DEBUG-level message to this FileLogger.

func (*FileLogger) DoDebug added in v1.0.1

func (l *FileLogger) DoDebug(d bool) (err error)

DoDebug sets the debug state of this FileLogger. Note that this merely acts as a *safety filter* for debug messages to avoid sensitive information being written to the log. err will always be nil; it's there for interface-compat.

func (*FileLogger) Emerg

func (l *FileLogger) Emerg(s string, v ...interface{}) (err error)

Emerg writes an EMERGENCY-level message to this FileLogger.

func (*FileLogger) Err

func (l *FileLogger) Err(s string, v ...interface{}) (err error)

Err writes an ERROR-level message to this FileLogger.

func (*FileLogger) GetDebug added in v1.4.0

func (l *FileLogger) GetDebug() (d bool)

GetDebug returns the debug status of this FileLogger.

func (*FileLogger) GetPrefix

func (l *FileLogger) GetPrefix() (prefix string, err error)

GetPrefix returns the prefix used by this FileLogger. err will always be nil; it's there for interface-compat.

func (*FileLogger) Info

func (l *FileLogger) Info(s string, v ...interface{}) (err error)

Info writes an INFO-level message to this FileLogger.

func (*FileLogger) Notice

func (l *FileLogger) Notice(s string, v ...interface{}) (err error)

Notice writes a NOTICE-level message to this FileLogger.

func (*FileLogger) SetPrefix added in v1.0.1

func (l *FileLogger) SetPrefix(prefix string) (err error)

SetPrefix sets the prefix for this FileLogger. err will always be nil; it's there for interface-compat.

func (*FileLogger) Setup

func (l *FileLogger) Setup() (err error)

Setup sets up/configures a FileLogger and prepares it for use.

func (*FileLogger) Shutdown

func (l *FileLogger) Shutdown() (err error)

Shutdown cleanly shuts down a FileLogger.

func (*FileLogger) Warning

func (l *FileLogger) Warning(s string, v ...interface{}) (err error)

Warning writes a WARNING/WARN-level message to this FileLogger.

type Logger

type Logger interface {
	Alert(s string, v ...interface{}) (err error)
	Crit(s string, v ...interface{}) (err error)
	Debug(s string, v ...interface{}) (err error)
	Emerg(s string, v ...interface{}) (err error)
	Err(s string, v ...interface{}) (err error)
	Info(s string, v ...interface{}) (err error)
	Notice(s string, v ...interface{}) (err error)
	Warning(s string, v ...interface{}) (err error)
	DoDebug(d bool) (err error)
	GetDebug() (d bool)
	SetPrefix(p string) (err error)
	GetPrefix() (p string, err error)
	Setup() (err error)
	Shutdown() (err error)
}

Logger is one of the various loggers offered by this module.

func GetLogger

func GetLogger(enableDebug bool, prefix string, logConfigFlags int, logPaths ...string) (logger Logger, err error)

GetLogger returns an instance of Logger that best suits your system's capabilities.

If enableDebug is true, debug messages (which according to your program may or may not contain sensitive data) are rendered and written.

If prefix is "\x00" (a null byte), then the default logging prefix will be used. If anything else, even an empty string, is specified then that will be used instead for the prefix.

logConfigFlags is the corresponding flag(s) OR'd for StdLogger.LogFlags / FileLogger.StdLogger.LogFlags if either is selected. See StdLogger.LogFlags and https://pkg.go.dev/log#pkg-constants for details.

logPaths is an (optional) list of strings to use as paths to test for writing. If the file can be created/written to, it will be used (assuming you have no higher-level loggers available). Only the first logPaths entry that "works" will be used, later entries will be ignored. If you want to log to multiple files simultaneously, use a MultiLogger instead.

If you call GetLogger, you will only get a single ("best") logger your system supports. If you want to log to multiple Logger destinations at once (or want to log to an explicit Logger type), use GetMultiLogger.

type MultiLogger added in v1.1.1

type MultiLogger struct {
	/*
		EnableDebug indicates if the debug filter should be disabled (true) or if the filter should be enabled (false).
		This prevents potential data leak of sensitive information, as some loggers (e.g. FileLogger) will otherwise write all messages.
	*/
	EnableDebug bool
	// Prefix indicates the prefix for log entries; in shared logs, this helps differentiate the source.
	Prefix string
	/*
		Loggers contains a map of map[logname]Logger. It can be used to set log-specific options, or replace a Logger
		with one of a different type or options.
	*/
	Loggers map[string]Logger
}

MultiLogger is used to contain one or more Loggers and present them all as a single Logger.

func GetMultiLogger added in v1.1.1

func GetMultiLogger(enableDebug bool, prefix string) (m *MultiLogger)

GetMultiLogger returns a MultiLogger. If you call GetLogger, you will only get a single ("best") logger your system supports. If you want to log to multiple Logger destinations at once (or want to log to an explicit Logger type), use GetMultiLogger.

Remember to add at least one Logger (e.g. MultiLogger.AddStdLogger), otherwise no entries will actually be logged.

If you want to modify e.g. if debug is enabled for a specific Logger, reference the Logger directly (e.g. MultiLogger.Loggers[identifier].SetDebug(false)).

func (*MultiLogger) AddDefaultLogger added in v1.1.1

func (m *MultiLogger) AddDefaultLogger(identifier string, logFlags int, logPaths ...string) (err error)

AddDefaultLogger adds a default Logger (as would be determined by GetLogger) to a MultiLogger.

identifier is a string to use to identify the added Logger in MultiLogger.Loggers. If empty, one will be automatically generated.

See the documentation for GetLogger for details on other arguments.

func (*MultiLogger) AddFileLogger added in v1.1.1

func (m *MultiLogger) AddFileLogger(identifier string, logFlags int, logfilePath string) (err error)

AddFileLogger adds a FileLogger to a MultiLogger.

identifier is a string to use to identify the added FileLogger in MultiLogger.Loggers. If empty, one will be automatically generated.

logfilePath is a string for the path to the desired logfile.

func (*MultiLogger) AddNullLogger added in v1.3.2

func (m *MultiLogger) AddNullLogger(identifier string) (err error)

AddNullLogger adds a NullLogger to a MultiLogger.

identifier is a string to use to identify the added NullLogger in MultiLogger.Loggers. If empty, one will be automatically generated.

func (*MultiLogger) AddStdLogger added in v1.1.1

func (m *MultiLogger) AddStdLogger(identifier string, enableStdOut, enableStdErr bool, logFlags int) (err error)

AddStdLogger adds a StdLogger to a MultiLogger.

identifier is a string to use to identify the added StdLogger in MultiLogger.Loggers. If empty, one will be automatically generated.

enableStdOut indicates that messages should be logged to STDOUT; it is *strongly encouraged* to set at least one of enableStdOut or enableStdErr to true.

enableStdErr indicates that messages should be logged to STDERR; it is *strongly encouraged* to set at least one of enableStdErr or enableStdOut to true.

See GetLogger's logConfigFlags argument and StdLogger.LogFlags for details on logFlags.

func (*MultiLogger) AddSysdLogger added in v1.1.1

func (m *MultiLogger) AddSysdLogger(identifier string) (err error)

AddSysdLogger adds a SystemDLogger to a MultiLogger.

identifier is a string to use to identify the added SystemDLogger in MultiLogger.Loggers. If empty, one will be automatically generated.

func (*MultiLogger) AddSyslogLogger added in v1.1.1

func (m *MultiLogger) AddSyslogLogger(identifier string) (err error)

AddSyslogLogger adds a SyslogLogger to a MultiLogger.

identifier is a string to use to identify the added SyslogLogger in MultiLogger.Loggers. If empty, one will be automatically generated.

func (*MultiLogger) Alert added in v1.1.1

func (m *MultiLogger) Alert(s string, v ...interface{}) (err error)

Alert writes an ALERT-level message to this MultiLogger (and all its MultiLogger.Loggers).

func (*MultiLogger) Crit added in v1.1.1

func (m *MultiLogger) Crit(s string, v ...interface{}) (err error)

Crit writes an CRITICAL-level message to this MultiLogger (and all its MultiLogger.Loggers).

func (*MultiLogger) Debug added in v1.1.1

func (m *MultiLogger) Debug(s string, v ...interface{}) (err error)

Debug writes a DEBUG-level message to this MultiLogger (and all its MultiLogger.Loggers).

func (*MultiLogger) DoDebug added in v1.1.1

func (m *MultiLogger) DoDebug(d bool) (err error)

DoDebug sets the debug state of this MultiLogger (and all its MultiLogger.Loggers). Note that this merely acts as a *safety filter* for debug messages to avoid sensitive information being written to the log.

If you had a logger-specific EnableDebug set, you will need to re-set it to your desired state after running this method.

func (*MultiLogger) Emerg added in v1.1.1

func (m *MultiLogger) Emerg(s string, v ...interface{}) (err error)

Emerg writes an EMERGENCY-level message to this MultiLogger (and all its MultiLogger.Loggers).

func (*MultiLogger) Err added in v1.1.1

func (m *MultiLogger) Err(s string, v ...interface{}) (err error)

Err writes an ERROR-level message to this MultiLogger (and all its MultiLogger.Loggers).

func (*MultiLogger) GetDebug added in v1.4.0

func (m *MultiLogger) GetDebug() (d bool)

GetDebug returns the debug status of this MultiLogger.

func (*MultiLogger) GetPrefix added in v1.1.1

func (m *MultiLogger) GetPrefix() (prefix string, err error)

GetPrefix returns the prefix used by this MultiLogger (and all its MultiLogger.Loggers). err will always be nil; it's there for interface-compat.

func (*MultiLogger) Info added in v1.1.1

func (m *MultiLogger) Info(s string, v ...interface{}) (err error)

Info writes an INFO-level message to this MultiLogger (and all its MultiLogger.Loggers).

func (*MultiLogger) Notice added in v1.1.1

func (m *MultiLogger) Notice(s string, v ...interface{}) (err error)

Notice writes a NOTICE-level message to this MultiLogger (and all its MultiLogger.Loggers).

func (*MultiLogger) RemoveLogger added in v1.1.1

func (m *MultiLogger) RemoveLogger(identifier string) (err error)

RemoveLogger will let you remove a Logger from MultiLogger.Loggers.

func (*MultiLogger) SetPrefix added in v1.1.1

func (m *MultiLogger) SetPrefix(prefix string) (err error)

SetPrefix sets the prefix for this MultiLogger (and all its MultiLogger.Loggers).

If you had a logger-specific Prefix set, you will need to re-set it to your desired prefix after running this method.

func (*MultiLogger) Setup added in v1.1.1

func (m *MultiLogger) Setup() (err error)

Setup sets up/configures a MultiLogger (and all its MultiLogger.Loggers) and prepares it for use.

func (*MultiLogger) Shutdown added in v1.1.1

func (m *MultiLogger) Shutdown() (err error)

Shutdown cleanly shuts down a MultiLogger (and all its MultiLogger.Loggers).

func (*MultiLogger) Warning added in v1.1.1

func (m *MultiLogger) Warning(s string, v ...interface{}) (err error)

Warning writes a WARNING/WARN-level message to this MultiLogger (and all its MultiLogger.Loggers).

type NullLogger added in v1.3.2

type NullLogger struct{}

NullLogger is used mainly for test implementations, mockup code, etc. It does absolutely nothing with all messages sent to it.

func (*NullLogger) Alert added in v1.3.2

func (l *NullLogger) Alert(s string, v ...interface{}) (err error)

Alert does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) Crit added in v1.3.2

func (l *NullLogger) Crit(s string, v ...interface{}) (err error)

Crit does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) Debug added in v1.3.2

func (l *NullLogger) Debug(s string, v ...interface{}) (err error)

Debug does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) DoDebug added in v1.3.2

func (l *NullLogger) DoDebug(d bool) (err error)

DoDebug does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) Emerg added in v1.3.2

func (l *NullLogger) Emerg(s string, v ...interface{}) (err error)

Emerg does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) Err added in v1.3.2

func (l *NullLogger) Err(s string, v ...interface{}) (err error)

Err does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) GetDebug added in v1.4.0

func (n *NullLogger) GetDebug() (d bool)

GetDebug returns the debug status of this NullLogger. It will always return true. 🙃

func (*NullLogger) GetPrefix added in v1.3.2

func (l *NullLogger) GetPrefix() (p string, err error)

GetPrefix does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) Info added in v1.3.2

func (l *NullLogger) Info(s string, v ...interface{}) (err error)

Info does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) Notice added in v1.3.2

func (l *NullLogger) Notice(s string, v ...interface{}) (err error)

Notice does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) SetPrefix added in v1.3.2

func (l *NullLogger) SetPrefix(p string) (err error)

SetPrefix does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) Setup added in v1.3.2

func (l *NullLogger) Setup() (err error)

Setup does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) Shutdown added in v1.3.2

func (l *NullLogger) Shutdown() (err error)

Shutdown does nothing at all; it's here for interface compat. 🙃

func (*NullLogger) Warning added in v1.3.2

func (l *NullLogger) Warning(s string, v ...interface{}) (err error)

Warning does nothing at all; it's here for interface compat. 🙃

type StdLogger

type StdLogger struct {
	// All log.Logger fields/methods are exposed.
	*log.Logger
	/*
		EnableDebug indicates if the debug filter should be disabled (true) or if the filter should be enabled (false).
		This prevents potential data leak of sensitive information, as some loggers (e.g. FileLogger) will otherwise write all messages.
	*/
	EnableDebug bool
	// Prefix indicates the prefix for log entries; in shared logs, this helps differentiate the source.
	Prefix string
	/*
		LogFlags control some of the formatting options presented as an OR'd value.
		See https://pkg.go.dev/log#pkg-constants for flag details.
		e.g.:
			*StdLogger.LogFlags = log.Ldate | log.Lmicroseconds | log.Llongfile | log.LUTC // a very detailed log output
			*StdLogger.LogFlags = log.Ldate | log.Ltime // the flags used by log.Default() (also available as simply log.LstdFlags)
		The default is 0; no flags (no output except prefix if non-empty and message).
		You will need to run *StdLogger.Shutdown and then *StdLogger.Setup again if you wish to change this.
	*/
	LogFlags int
	/*
		EnableStdOut is true if the log will send to STDOUT.
		If false (default), no output will be written to STDOUT.
		You will need to run StdLogger.Shutdown and then StdLogger.Setup again if you wish to change this.

		If EnableStdOut is false and EnableStdErr is false, no logging output will occur by default
		and StdLogger.Logger will be largely useless.
		It will be up to you to modify the underlying log.Logger to behave as you want.
	*/
	EnableStdOut bool
	/*
		EnableStdErr is true if the log will send to STDERR.
		If false (default), no output will be written to STDERR.
		You will need to run StdLogger.Shutdown and then StdLogger.Setup again if you wish to change this.

		If EnableStdErr is false and EnableStdOut is false, no logging output will occur by default
		and StdLogger.Logger will be largely useless.
		It will be up to you to modify the underlying log.Logger to behave as you want.
	*/
	EnableStdErr bool
}

StdLogger uses the log package in stdlib to perform all logging. The default is to write to STDOUT. If you wish to modify the underling log.Logger object, you can access it directly via StdLogger.Logger.

func (*StdLogger) Alert

func (l *StdLogger) Alert(s string, v ...interface{}) (err error)

Alert writes an ALERT-level message to this StdLogger.

func (*StdLogger) Crit

func (l *StdLogger) Crit(s string, v ...interface{}) (err error)

Crit writes an CRITICAL-level message to this StdLogger.

func (*StdLogger) Debug

func (l *StdLogger) Debug(s string, v ...interface{}) (err error)

Debug writes a DEBUG-level message to this StdLogger.

func (*StdLogger) DoDebug added in v1.0.1

func (l *StdLogger) DoDebug(d bool) (err error)

DoDebug sets the debug state of this StdLogger. Note that this merely acts as a *safety filter* for debug messages to avoid sensitive information being written to the log. err will always be nil; it's there for interface-compat.

func (*StdLogger) Emerg

func (l *StdLogger) Emerg(s string, v ...interface{}) (err error)

Emerg writes an EMERGENCY-level message to this StdLogger.

func (*StdLogger) Err

func (l *StdLogger) Err(s string, v ...interface{}) (err error)

Err writes an ERROR-level message to this StdLogger.

func (*StdLogger) GetDebug added in v1.4.0

func (l *StdLogger) GetDebug() (d bool)

GetDebug returns the debug status of this StdLogger.

func (*StdLogger) GetPrefix

func (l *StdLogger) GetPrefix() (prefix string, err error)

GetPrefix returns the prefix used by this StdLogger. err will always be nil; it's there for interface-compat.

func (*StdLogger) Info

func (l *StdLogger) Info(s string, v ...interface{}) (err error)

Info writes an INFO-level message to this StdLogger.

func (*StdLogger) Notice

func (l *StdLogger) Notice(s string, v ...interface{}) (err error)

Notice writes a NOTICE-level message to this StdLogger.

func (*StdLogger) SetPrefix added in v1.0.1

func (l *StdLogger) SetPrefix(prefix string) (err error)

SetPrefix sets the prefix for this StdLogger. err will always be nil; it's there for interface-compat.

func (*StdLogger) Setup

func (l *StdLogger) Setup() (err error)

Setup sets up/configures a StdLogger and prepares it for use. err will always be nil; it's there for interface-compat.

func (*StdLogger) Shutdown

func (l *StdLogger) Shutdown() (err error)

Shutdown cleanly shuts down a StdLogger. err will always be nil; it's there for interface-compat.

func (*StdLogger) Warning

func (l *StdLogger) Warning(s string, v ...interface{}) (err error)

Warning writes a WARNING/WARN-level message to this StdLogger.

type SyslogLogger

type SyslogLogger struct {
	EnableDebug bool
	Prefix      string
	// contains filtered or unexported fields
}

SyslogLogger writes to syslog on syslog-enabled systems.

func (*SyslogLogger) Alert

func (l *SyslogLogger) Alert(s string, v ...interface{}) (err error)

Alert writes an ALERT-level message to this SyslogLogger.

func (*SyslogLogger) Crit

func (l *SyslogLogger) Crit(s string, v ...interface{}) (err error)

Crit writes an CRITICAL-level message to this SyslogLogger.

func (*SyslogLogger) Debug

func (l *SyslogLogger) Debug(s string, v ...interface{}) (err error)

Debug writes a DEBUG-level message to this SyslogLogger.

func (*SyslogLogger) DoDebug added in v1.0.1

func (l *SyslogLogger) DoDebug(d bool) (err error)

DoDebug sets the debug state of this SyslogLogger. Note that this merely acts as a *safety filter* for debug messages to avoid sensitive information being written to the log. err will always be nil; it's there for interface-compat.

func (*SyslogLogger) Emerg

func (l *SyslogLogger) Emerg(s string, v ...interface{}) (err error)

Emerg writes an EMERGENCY-level message to this SyslogLogger.

func (*SyslogLogger) Err

func (l *SyslogLogger) Err(s string, v ...interface{}) (err error)

Err writes an ERROR-level message to this SyslogLogger.

func (*SyslogLogger) GetDebug added in v1.4.0

func (l *SyslogLogger) GetDebug() (d bool)

GetDebug returns the debug status of this SyslogLogger.

func (*SyslogLogger) GetPrefix

func (l *SyslogLogger) GetPrefix() (prefix string, err error)

GetPrefix returns the prefix used by this SyslogLogger. err will always be nil; it's there for interface-compat.

func (*SyslogLogger) Info

func (l *SyslogLogger) Info(s string, v ...interface{}) (err error)

Info writes an INFO-level message to this SyslogLogger.

func (*SyslogLogger) Notice

func (l *SyslogLogger) Notice(s string, v ...interface{}) (err error)

Notice writes a NOTICE-level message to this SyslogLogger.

func (*SyslogLogger) SetPrefix added in v1.0.1

func (l *SyslogLogger) SetPrefix(prefix string) (err error)

SetPrefix sets the prefix for this SyslogLogger.

func (*SyslogLogger) Setup

func (l *SyslogLogger) Setup() (err error)

Setup sets up/configures a SyslogLogger and prepares it for use.

func (*SyslogLogger) Shutdown

func (l *SyslogLogger) Shutdown() (err error)

Shutdown cleanly shuts down a SyslogLogger.

func (*SyslogLogger) Warning

func (l *SyslogLogger) Warning(s string, v ...interface{}) (err error)

Warning writes a WARNING/WARN-level message to this SyslogLogger.

type SystemDLogger

type SystemDLogger struct {
	EnableDebug bool
	Prefix      string
}

SystemDLogger (yes, I'm aware it's actually written as "systemd") writes to journald on systemd-enabled systems.

func (*SystemDLogger) Alert

func (l *SystemDLogger) Alert(s string, v ...interface{}) (err error)

Alert writes an ALERT-level message to this SystemDLogger.

func (*SystemDLogger) Crit

func (l *SystemDLogger) Crit(s string, v ...interface{}) (err error)

Crit writes an CRITICAL-level message to this SystemDLogger.

func (*SystemDLogger) Debug

func (l *SystemDLogger) Debug(s string, v ...interface{}) (err error)

Debug writes a DEBUG-level message to this SystemDLogger.

func (*SystemDLogger) DoDebug added in v1.0.1

func (l *SystemDLogger) DoDebug(d bool) (err error)

DoDebug sets the debug state of this SystemDLogger. Note that this merely acts as a *safety filter* for debug messages to avoid sensitive information being written to the log. err will always be nil; it's there for interface-compat.

func (*SystemDLogger) Emerg

func (l *SystemDLogger) Emerg(s string, v ...interface{}) (err error)

Emerg writes an EMERGENCY-level message to this SystemDLogger.

func (*SystemDLogger) Err

func (l *SystemDLogger) Err(s string, v ...interface{}) (err error)

Err writes an ERROR-level message to this SystemDLogger.

func (*SystemDLogger) GetDebug added in v1.4.0

func (l *SystemDLogger) GetDebug() (d bool)

GetDebug returns the debug status of this SystemDLogger.

func (*SystemDLogger) GetPrefix

func (l *SystemDLogger) GetPrefix() (prefix string, err error)

GetPrefix returns the prefix used by this SystemDLogger. err will always be nil; it's there for interface-compat.

func (*SystemDLogger) Info

func (l *SystemDLogger) Info(s string, v ...interface{}) (err error)

Info writes an INFO-level message to this SystemDLogger.

func (*SystemDLogger) Notice

func (l *SystemDLogger) Notice(s string, v ...interface{}) (err error)

Notice writes a NOTICE-level message to this SystemDLogger.

func (*SystemDLogger) SetPrefix added in v1.0.1

func (l *SystemDLogger) SetPrefix(prefix string) (err error)

SetPrefix sets the prefix for this SystemDLogger. err will always be nil; it's there for interface-compat.

func (*SystemDLogger) Setup

func (l *SystemDLogger) Setup() (err error)

Setup sets up/configures a SystemDLogger and prepares it for use. err will always be nil; it's there for interface-compat.

func (*SystemDLogger) Shutdown

func (l *SystemDLogger) Shutdown() (err error)

Shutdown cleanly shuts down a SystemDLogger. err will always be nil; it's there for interface-compat.

func (*SystemDLogger) Warning

func (l *SystemDLogger) Warning(s string, v ...interface{}) (err error)

Warning writes a WARNING/WARN-level message to this SystemDLogger.

Jump to

Keyboard shortcuts

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