luci: Index | Files

package renderer

import ""

Package renderer exports the capability to render a LogDog log stream to an io.Writer.

- Text streams are rendered by emitting the logs and their newlines in
- Binary streams are rendered by emitting the sequential binary data


Package Files

renderer.go source.go

type DatagramWriter Uses

type DatagramWriter func(io.Writer, []byte) bool

DatagramWriter is a callback function that, given datagram bytes, writes them to the specified io.Writer.

Returns true if the datagram was successfully rendered, false if it could not be.

type Renderer Uses

type Renderer struct {
    // Source is the log Source to use to retrieve the logs to render.
    Source Source

    // Raw, if true, attempts to reproduce the original stream data rather
    // than pretty-rendering it.
    // - For text streams, this means using the original streams' encoding and
    //   newline delimiters. If this is false, UTF8 and "\n" will be used.
    // - For binary and datagram streams, this skips any associated
    //   DatagramWriters and hex translation and dumps data directly to output.
    Raw bool

    // TextPrefix, if not nil, is called prior to rendering a text line. The
    // resulting string is prepended to that text line on render.
    TextPrefix func(le *logpb.LogEntry, line *logpb.Text_Line) string

    // DatagramWriter is a function to call to render a complete datagram stream.
    // If it returns false, or if nil, a hex dump renderer will be used to
    // render the datagram.
    DatagramWriter DatagramWriter
    // contains filtered or unexported fields

Renderer is a stateful instance that provides an io.Reader interface to a log stream.

func (*Renderer) Read Uses

func (r *Renderer) Read(b []byte) (int, error)

type Source Uses

type Source interface {
    // NextLogEntry returns the next successive LogEntry record to render, or an
    // error if it could not be retrieved.
    // If there are no more log entries in the stream, NextLogEntry should return
    // io.EOF as an error.
    // It is valid to return a LogEntry and an error (including io.EOF) at the
    // same time. The LogEntry will be processed before the error.
    NextLogEntry() (*logpb.LogEntry, error)

Source returns successive LogEntry records for processing.

type StaticSource Uses

type StaticSource []*logpb.LogEntry

StaticSource is a Source that returns successive log entries from a slice of log entries. The slice is mutated during processing.

func (*StaticSource) NextLogEntry Uses

func (s *StaticSource) NextLogEntry() (le *logpb.LogEntry, err error)

NextLogEntry implements Source.

Package renderer imports 5 packages (graph) and is imported by 7 packages. Updated 2021-01-21. Refresh now. Tools for package owners.