Documentation ¶
Index ¶
- type Adapter
- type Brr
- func (brr *Brr) Debug(mode ...bool) bool
- func (brr *Brr) Debugf(format string, a ...interface{})
- func (brr *Brr) Debugln(a ...interface{})
- func (brr *Brr) Flush()
- func (brr *Brr) Func(namekind, id string) *Brr
- func (brr *Brr) Gofunc(namekind, id string, f func(*Brr))
- func (brr *Brr) Printf(format string, a ...interface{})
- func (brr *Brr) Println(a ...interface{})
- type Chunk
- type Config
- type Example
- type Flag
- type Motor
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶ added in v0.7.7
type Adapter interface { // Begin is called whenever a procedure is started. Begin(*Brr) // Write manages the log transformation. // // This function transforms the provided chunk into // the intermediate batching buffer in charge of the // flush valve. Write(brr *Brr, chunk Chunk, w io.Writer) // End is called just before the final flush. End(*Brr) // "Real" destination of the log stream. // // The log writes are flushed here at the most suitable // time to minimize memory use and I/O pressure due to // irregular writes typical for logging. Device() io.Writer // Max allowed time-to-flush for any given write. // // Returns negative if unlimited. TTF() time.Duration }
Adapter is how motor interacts with the destination I/O.
type Brr ¶ added in v0.7.7
type Brr struct { // (Not unique) one of a kind name (ie. /endpoint) Namekind string // (Unique) context (request) identifier. Id string // Start time T0 time.Time // contains filtered or unexported fields }
Brr is the procedural log context.
If constructed from Func or Gofunc, it will attempt to predict both the average log size and time to flush in order to utilize memory most efficiently.
func (*Brr) Debug ¶ added in v0.7.7
If set to true, Debugf/ln writes will come through.
func (*Brr) Debugf ¶ added in v0.7.7
Debugf is the debug mode Printf counterpart.
If the context is not debugging, this function will return false immediately without ever consulting the log buffer.
func (*Brr) Debugln ¶ added in v0.7.7
func (brr *Brr) Debugln(a ...interface{})
Debugln is the debug mode Println counterpart.
If the context is not debugging, this function will return false immediately without ever consulting the log buffer.
func (*Brr) Flush ¶ added in v0.7.7
func (brr *Brr) Flush()
Flush orders the final flush of the log buffer.
This function is called when there's no more work to be done per the existing context. All further writes will be ignored.
func (*Brr) Func ¶ added in v0.7.7
Func consructs a new motorised log.
This function will allocate a new log buffer according to the estimate of procedure demands known at the time of its creation.
Use consistent procedure names.
func (*Brr) Gofunc ¶ added in v0.7.7
Gofunc constructs a new asynchronous context.
func (*Brr) Printf ¶ added in v0.7.7
Printf puts a fragment of a message into the log buffer.
type Chunk ¶ added in v0.7.7
type Chunk struct { // Printf format string, if provided. Format string Args []interface{} // Named printf arguments (tags) list. Tags []Tag Flags []Flag // True if the chunk is a debug write in itself. Debug bool }
Chunk represents a single log write to the log buffer.
func (Chunk) Autowrite ¶ added in v0.7.7
Autowrite prints (and formats) chunk arguments.
type Config ¶ added in v0.7.7
type Config struct { // If true, motor will let debug writes through. Debug bool // Motor can write into multiple devices simultaneously. // // For example, you can have human-readable formatted // messages end up in stdout, structured JSON log in // the dedicated log file, and have a seperate exhaust // reserved for metrics only. Sinks []Adapter }
Config is a set of preferences required to start it.
type Example ¶ added in v0.7.8
type Example struct { }
Example is a basic adapter with terminal formatting.