Documentation ¶
Overview ¶
Package clog is a concurrent log. It stores log entries in a buffer and writes (flushes) them out when the log buffer is full. Log entries that are in memory (not flushed) can be searched and counted. Multiple goroutines can log concurrently without blocking, even if there is an ongoing flush or search.
Index ¶
- type Entry
- type Error
- type Fatal
- type Info
- type Log
- func (l *Log) Count(match func(fmt.Stringer) bool) int
- func (l *Log) Error(a ...interface{})
- func (l *Log) Fatal(a ...interface{})
- func (l *Log) Flush()
- func (l *Log) Info(a ...interface{})
- func (l *Log) Initialize(size int, out io.Writer, bufsize int)
- func (l *Log) Log(s fmt.Stringer)
- func (l *Log) LogPrint(a ...interface{})
- func (l *Log) Search(match func(fmt.Stringer) bool) []fmt.Stringer
- func (l *Log) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is the main log type. Must be initialized before use.
func (*Log) Error ¶
func (l *Log) Error(a ...interface{})
Error logs an error. It will be prefixed with 'error:'.
func (*Log) Fatal ¶
func (l *Log) Fatal(a ...interface{})
Fatal logs the error then exits the program.
func (*Log) Flush ¶
func (l *Log) Flush()
Flush log contents. Will not flush contents of temporary buffer (use Stop for that).
func (*Log) Initialize ¶
Initialize a new logger. Parameter size determines the number of events to hold before flushing to out. Parameter out is the writer used to store log entries on a flush (can be nil). Parameter bufsize is the size of the temporary buffer used to avoid stalls. If set to zero log call block.