micro/debug/log/log.go

43 lines
835 B
Go
Raw Normal View History

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