41 lines
737 B
Go
41 lines
737 B
Go
// Package log provides debug logging
|
|
package log
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
// DefaultLog logger
|
|
DefaultLog = NewLog()
|
|
// DefaultLevel is default log level
|
|
DefaultLevel = LevelInfo
|
|
// prefix for all messages
|
|
prefix string
|
|
)
|
|
|
|
// Log is event log
|
|
type Log interface {
|
|
// Read reads log entries from the logger
|
|
Read(...ReadOption) ([]Record, error)
|
|
// Write writes records to log
|
|
Write(Record) error
|
|
// Stream log records
|
|
Stream() (Stream, error)
|
|
}
|
|
|
|
// Record is log record entry
|
|
type Record struct {
|
|
// Timestamp of logged event
|
|
Timestamp time.Time
|
|
// Value contains log entry
|
|
Value interface{}
|
|
// Metadata to enrich log record
|
|
Metadata map[string]string
|
|
}
|
|
|
|
type Stream interface {
|
|
Chan() <-chan Record
|
|
Stop() error
|
|
}
|