Documentation
¶
Overview ¶
Package flog provides facilities for using and managing file-backed logger objects.
Index ¶
- Constants
- type BufferedLog
- func (this *BufferedLog) BaseDir() string
- func (this *BufferedLog) BufferCap() int
- func (this *BufferedLog) Close()
- func (this *BufferedLog) FlushIntervalSec() int32
- func (this *BufferedLog) Name() string
- func (this *BufferedLog) Print(msg *xlog.LogMsg)
- func (this *BufferedLog) SetEnabled(enabled bool)
- func (this *BufferedLog) SetFlushIntervalSec(interval int32)
- type DirectLog
- type FLog
Constants ¶
const ( FLUSH_DEFAULTS = iota FLUSH_FORCED )
const ( BufferedFile = iota DirectFile )
Enumeration of different FLog implementations.
const DefaultFlushIntervalSec = 5
Default flush interval, in seconds, for BufferedLog instances.
Log file open flags.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferedLog ¶
type BufferedLog struct {
// contains filtered or unexported fields
}
BufferedLog represents a buffered, file-backed logger and enforces a standardized logging format. New logging entries are sent to a memory buffer and periodically flushed to the backing file at configurable intervals by a separate goroutine.
func (*BufferedLog) BaseDir ¶
func (this *BufferedLog) BaseDir() string
BaseDir returns the base directory of the file backing this BufferedLog instance.
func (*BufferedLog) BufferCap ¶
func (this *BufferedLog) BufferCap() int
BufferCap returns the current capacity of the underlying memory buffer.
func (*BufferedLog) Close ¶
func (this *BufferedLog) Close()
Close disables the BufferedLog instance, flushes any remaining entries to disk, and then closes the backing log file.
func (*BufferedLog) FlushIntervalSec ¶
func (this *BufferedLog) FlushIntervalSec() int32
FlushInterval returns the interval between log flushes in seconds.
func (*BufferedLog) Name ¶
func (this *BufferedLog) Name() string
Name returns the friendly name of the log.
func (*BufferedLog) Print ¶
func (this *BufferedLog) Print(msg *xlog.LogMsg)
Print formats and buffers a new log entry as long as the BufferedLog instance is enabled.
func (*BufferedLog) SetEnabled ¶
func (this *BufferedLog) SetEnabled(enabled bool)
SetEnabled temporarily enables/disables the log instance.
func (*BufferedLog) SetFlushIntervalSec ¶
func (this *BufferedLog) SetFlushIntervalSec(interval int32)
SetFlushIntervalSec sets the interval at which the log buffer worker will attempt to flush new entries into the backing log file.
type DirectLog ¶
type DirectLog struct {
// contains filtered or unexported fields
}
DirectLog represents a file-backed logger and enforces a standardized logging format. New logging entries are written immediately to the backing file.
func (*DirectLog) BaseDir ¶
BaseDir returns the base directory of the file backing this DirectLog instance.
func (*DirectLog) Close ¶
func (this *DirectLog) Close()
Close disables the DirectLog instance, flushes any remaining entries to disk, and then closes the backing log file.
func (*DirectLog) Print ¶
Print formats and buffers a new log entry as long as the DirectLog instance is enabled.
func (*DirectLog) SetEnabled ¶
SetEnabled temporarily enables/disables the DirectLog instance.
type FLog ¶
type FLog interface { BaseDir() string Close() SetEnabled(bool) Name() string Print(msg *xlog.LogMsg) }
FLog provides a common interface for different file-backed logs. This package includes two primary implementations; BufferedLog and DirectLog.