2019-11-27 18:02:16 +02:00
|
|
|
// Package log provides debug logging
|
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
2019-11-27 19:31:35 +02:00
|
|
|
"time"
|
2019-11-27 18:02:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-11-28 13:36:38 +02:00
|
|
|
// DefaultLog logger
|
|
|
|
DefaultLog = NewLog()
|
|
|
|
// DefaultLevel is default log level
|
|
|
|
DefaultLevel = LevelInfo
|
2019-11-27 18:02:16 +02:00
|
|
|
// prefix for all messages
|
|
|
|
prefix string
|
|
|
|
)
|
|
|
|
|
2019-11-27 19:31:35 +02:00
|
|
|
// Log is event log
|
|
|
|
type Log interface {
|
|
|
|
// Read reads log entries from the logger
|
2019-12-17 18:56:55 +02:00
|
|
|
Read(...ReadOption) ([]Record, error)
|
2019-12-01 15:15:10 +02:00
|
|
|
// Write writes records to log
|
2019-12-17 18:56:55 +02:00
|
|
|
Write(Record) error
|
2019-12-01 15:15:10 +02:00
|
|
|
// Stream log records
|
2019-12-17 18:56:55 +02:00
|
|
|
Stream() (Stream, error)
|
2019-11-27 18:02:16 +02:00
|
|
|
}
|
|
|
|
|
2019-11-27 19:31:35 +02:00
|
|
|
// Record is log record entry
|
|
|
|
type Record struct {
|
|
|
|
// Timestamp of logged event
|
2019-12-17 18:09:51 +02:00
|
|
|
Timestamp time.Time `json:"time"`
|
2019-11-27 19:31:35 +02:00
|
|
|
// Value contains log entry
|
2019-12-17 18:09:51 +02:00
|
|
|
Value interface{} `json:"value"`
|
2019-11-27 19:31:35 +02:00
|
|
|
// Metadata to enrich log record
|
2019-12-17 18:09:51 +02:00
|
|
|
Metadata map[string]string `json:"metadata"`
|
2019-11-27 19:31:35 +02:00
|
|
|
}
|
|
|
|
|
2019-12-17 18:56:55 +02:00
|
|
|
type Stream interface {
|
|
|
|
Chan() <-chan Record
|
|
|
|
Stop() error
|
2019-11-27 18:02:16 +02:00
|
|
|
}
|