Documentation ¶
Index ¶
- func LevelFilter() *logutils.LevelFilter
- func Setup(config *Config, ui cli.Ui) (*logutils.LevelFilter, *GatedWriter, *LogWriter, io.Writer, bool)
- func ValidateLevelFilter(minLevel logutils.LogLevel, filter *logutils.LevelFilter) bool
- type Config
- type GatedWriter
- type LogHandler
- type LogWriter
- type SyslogWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LevelFilter ¶
func LevelFilter() *logutils.LevelFilter
LevelFilter returns a LevelFilter that is configured with the log levels that we use.
func Setup ¶
func Setup(config *Config, ui cli.Ui) (*logutils.LevelFilter, *GatedWriter, *LogWriter, io.Writer, bool)
Setup is used to perform setup of several logging objects:
- A LevelFilter is used to perform filtering by log level.
- A GatedWriter is used to buffer logs until startup UI operations are complete. After this is flushed then logs flow directly to output destinations.
- A LogWriter provides a mean to temporarily hook logs, such as for running a command like "consul monitor".
- An io.Writer is provided as the sink for all logs to flow to.
The provided ui object will get any log messages related to setting up logging itself, and will also be hooked up to the gated logger. The final bool parameter indicates if logging was set up successfully.
func ValidateLevelFilter ¶
func ValidateLevelFilter(minLevel logutils.LogLevel, filter *logutils.LevelFilter) bool
ValidateLevelFilter verifies that the log levels within the filter are valid.
Types ¶
type Config ¶
type Config struct { // LogLevel is the minimum level to be logged. LogLevel string // EnableSyslog controls forwarding to syslog. EnableSyslog bool // SyslogFacility is the destination for syslog forwarding. SyslogFacility string }
Config is used to set up logging.
type GatedWriter ¶
GatedWriter is an io.Writer implementation that buffers all of its data into an internal buffer until it is told to let data through.
func (*GatedWriter) Flush ¶
func (w *GatedWriter) Flush()
Flush tells the GatedWriter to flush any buffered data and to stop buffering.
type LogHandler ¶
type LogHandler interface {
HandleLog(string)
}
LogHandler interface is used for clients that want to subscribe to logs, for example to stream them over an IPC mechanism
type LogWriter ¶
LogWriter implements io.Writer so it can be used as a log sink. It maintains a circular buffer of logs, and a set of handlers to which it can stream the logs to.
func NewLogWriter ¶
NewLogWriter creates a LogWriter with the given buffer capacity
func (*LogWriter) DeregisterHandler ¶
func (l *LogWriter) DeregisterHandler(lh LogHandler)
DeregisterHandler removes a LogHandler and prevents more invocations
func (*LogWriter) RegisterHandler ¶
func (l *LogWriter) RegisterHandler(lh LogHandler)
RegisterHandler adds a log handler to receive logs, and sends the last buffered logs to the handler
type SyslogWrapper ¶
type SyslogWrapper struct {
// contains filtered or unexported fields
}
SyslogWrapper is used to cleanup log messages before writing them to a Syslogger. Implements the io.Writer interface.