Documentation
¶
Index ¶
Constants ¶
const ( SyslogName = "syslog" DatabaseName = "database" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferedLogger ¶
type BufferedLogger struct {
// contains filtered or unexported fields
}
BufferedLogger wraps a Logger, providing a buffer that accumulates log messages, flushing them to the underlying logger when enough messages have been accumulated.
func NewBufferedLogger ¶
func NewBufferedLogger( l Logger, bufferSize int, flushInterval time.Duration, clock clock.Clock, ) *BufferedLogger
NewBufferedLogger returns a new BufferedLogger, wrapping the given Logger with a buffer of the specified size and flush interval.
func (*BufferedLogger) Flush ¶
func (b *BufferedLogger) Flush() error
Flush flushes any buffered log records to the underlying Logger.
func (*BufferedLogger) Log ¶
func (b *BufferedLogger) Log(in []LogRecord) error
Log is part of the Logger interface.
BufferedLogger's Log implementation will buffer log records up to the specified capacity and duration; after either of which is exceeded, the records will be flushed to the underlying logger.
type Label ¶
type Label = string
Label represents a common logger label type.
const ( // HTTP defines a common HTTP request label. HTTP Label = "http" // METRICS defines a common label for dealing with metric output. This // should be used as a fallback for when prometheus isn't available. METRICS Label = "metrics" // CHARMHUB defines a common label for dealing with the charmhub client // and callers. CHARMHUB Label = "charmhub" // CMR defines a common label for dealing with cross model relations. CMR Label = "cmr" // CMR_AUTH defines a common label for dealing with cross model relations auth. CMR_AUTH Label = "cmr-auth" // SECRETS defines a common label for dealing with secrets. SECRETS Label = "secrets" // MIGRATION defines a common label for dealing with migration. MIGRATION Label = "migration" )
type LogRecord ¶
type LogRecord struct { // universal fields ID int64 Time time.Time // origin fields ModelUUID string Entity string Version version.Number // logging-specific fields Level loggo.Level Module string Location string Message string Labels []string }
LogRecord defines a single Juju log message as returned by LogTailer.
type LogTailer ¶
type LogTailer interface { // Logs returns the channel through which the LogTailer returns Juju logs. // It will be closed when the tailer stops. Logs() <-chan *LogRecord // Dying returns a channel which will be closed as the LogTailer stops. Dying() <-chan struct{} // Stop is used to request that the LogTailer stops. // It blocks until the LogTailer has stopped. Stop() error // Err returns the error that caused the LogTailer to stopped. // If it hasn't stopped or stopped without error nil will be returned. Err() error }
LogTailer allows for retrieval of Juju's logs. It first returns any matching already recorded logs and then waits for additional matching logs as they appear.
type LogTailerParams ¶
type LogTailerParams struct { StartID int64 StartTime time.Time MinLevel loggo.Level InitialLines int NoTail bool IncludeEntity []string ExcludeEntity []string IncludeModule []string ExcludeModule []string IncludeLabel []string ExcludeLabel []string FromTheStart bool }
LogTailerParams specifies the filtering a LogTailer should apply to log records in order to decide which to return.
type Logger ¶
type Logger interface { // Log writes the given log records to the logger's storage. Log([]LogRecord) error }
Logger provides an interface for writing log records.
type LoggerCloser ¶
LoggerCloser is a Logger that can be closed.
func MakeLoggers ¶
func MakeLoggers(outputs []string, config LoggersConfig) LoggerCloser
MakeLoggers creates loggers from a given LoggersConfig.
type LoggersConfig ¶
LoggersConfig defines a set of loggers that can be used to construct the final loggers.
type TeeLogger ¶
type TeeLogger struct {
// contains filtered or unexported fields
}
TeeLogger forwards log request to each underlying logger.
func NewTeeLogger ¶
NewTeeLogger returns a logger that forwards log requests to each one of the provided loggers.