1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00
go-micro/debug/log/log.go
2019-12-17 18:34:21 +00:00

40 lines
798 B
Go

// Package log provides debug logging
package log
import (
"time"
)
var (
// Default buffer size if any
DefaultSize = 1024
// DefaultLog logger
DefaultLog = NewLog()
)
// Log is debug log interface for reading and writing logs
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 `json:"time"`
// Value contains log entry
Value interface{} `json:"value"`
// Metadata to enrich log record
Metadata map[string]string `json:"metadata"`
}
// Stream returns a log stream
type Stream interface {
Chan() <-chan Record
Stop() error
}