inertia: Index | Files

package log

import ""

Package log provides logging utilities


Package Files

doc.go routine.go streamer.go writers.go

func FlushRoutine Uses

func FlushRoutine(w io.Writer, rc io.Reader, stop chan struct{})

FlushRoutine continuously writes everything in given ReadCloser to an io.Writer. Use this as a goroutine.

func WriteAndFlush Uses

func WriteAndFlush(w io.Writer, reader *bufio.Reader) error

WriteAndFlush reads from buffer, writes to writer, and flushes if possible

type CloseOpts Uses

type CloseOpts struct {
    Message    string
    StatusCode int

CloseOpts defines options for closing the logger

type MultiWriter Uses

type MultiWriter struct {
    // contains filtered or unexported fields

MultiWriter writes to list of writers without caring whether one fails, and flushes if writer is flushable

func (*MultiWriter) Write Uses

func (m *MultiWriter) Write(p []byte) (int, error)

type SocketWriter Uses

type SocketWriter interface {
    WriteMessage(messageType int, bytes []byte) error
    CloseHandler() func(code int, text string) error

SocketWriter is an interface for writing to websocket connections

type Streamer Uses

type Streamer struct {
    // contains filtered or unexported fields

Streamer is a multilogger used by the daemon to pipe output to multiple places depending on context.

func NewStreamer Uses

func NewStreamer(opts StreamerOptions) *Streamer

NewStreamer creates a new streamer. It must be closed if a Socket is provided, and one of Error() or Success() should be called.

func (*Streamer) Close Uses

func (s *Streamer) Close(opts ...CloseOpts) error

Close shuts down the logger

func (*Streamer) Error Uses

func (s *Streamer) Error(res *res.ErrResponse)

Error directs message and status to http.Error when appropriate

func (*Streamer) GetSocketWriter Uses

func (s *Streamer) GetSocketWriter() (io.Writer, error)

GetSocketWriter retrieves the socketwriter as an io.Writer

func (*Streamer) Println Uses

func (s *Streamer) Println(a ...interface{})

Println prints to logger's standard writer

func (*Streamer) Success Uses

func (s *Streamer) Success(res *res.MsgResponse)

Success directs status to Header and sets content type when appropriate

type StreamerOptions Uses

type StreamerOptions struct {
    Request    *http.Request
    Stdout     io.Writer
    Socket     SocketWriter
    HTTPWriter http.ResponseWriter
    HTTPStream bool

StreamerOptions defines configuration for a daemon streamer

type WebSocketWriter Uses

type WebSocketWriter struct {
    // contains filtered or unexported fields

WebSocketWriter wraps a SocketWriter in an io.Writer

func NewWebSocketTextWriter Uses

func NewWebSocketTextWriter(socket SocketWriter) *WebSocketWriter

NewWebSocketTextWriter returns an io.Writer version of SocketWriter

func (*WebSocketWriter) Close Uses

func (w *WebSocketWriter) Close() error

Close closes the socket writer's websocket.

func (*WebSocketWriter) Write Uses

func (w *WebSocketWriter) Write(p []byte) (int, error)

Package log imports 8 packages (graph) and is imported by 3 packages. Updated 2020-03-17. Refresh now. Tools for package owners.