Documentation
¶
Overview ¶
Package accesslog provides access log for banyandb.
Index ¶
Constants ¶
View Source
const ( // DefaultBatchSize is the default number of requests to batch before writing to the file. DefaultBatchSize = 100 // DefaultFlushInterval is the default interval at which to flush the batch to the file. DefaultFlushInterval = 1 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Log ¶
type Log interface {
// Write writes the access log.
Write(req proto.Message) error
// WriteQuery writes the query access log with timing information.
WriteQuery(service string, startTime time.Time, duration time.Duration, req proto.Message, err error) error
// Close closes the access log.
Close() error
}
Log is the interface for access log.
func NewFileLog ¶
func NewFileLog(root, template string, interval time.Duration, log *logger.Logger, sampled bool) (Log, error)
NewFileLog creates a new file access log. sampled: if true (default), requests may be dropped when the channel is full. If false, requests are never dropped but use buffered channel to prevent blocking.
type QueryLogEntry ¶ added in v0.9.0
type QueryLogEntry struct {
StartTime time.Time
Request proto.Message
Service string
Error string
Duration time.Duration
}
QueryLogEntry wraps a query request with execution timing information.
func NewQueryLogEntry ¶ added in v0.9.0
func NewQueryLogEntry(service string, startTime time.Time, duration time.Duration, request proto.Message, err error) *QueryLogEntry
NewQueryLogEntry creates a new query log entry with timing information.
func (*QueryLogEntry) Marshal ¶ added in v0.9.0
func (l *QueryLogEntry) Marshal() ([]byte, error)
Marshal marshals the log entry to JSON.
Click to show internal directories.
Click to hide internal directories.