log

package
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package log provides logging utilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlushRoutine

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

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

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

Types

type CloseOpts added in v0.5.0

type CloseOpts struct {
	Message    string
	StatusCode int
}

CloseOpts defines options for closing the logger

type DaemonLogger

type DaemonLogger struct {
	io.Writer
	// contains filtered or unexported fields
}

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

func NewLogger

func NewLogger(opts LoggerOptions) *DaemonLogger

NewLogger creates a new logger

func (*DaemonLogger) Close

func (l *DaemonLogger) Close(opts ...CloseOpts) error

Close shuts down the logger

func (*DaemonLogger) GetSocketWriter

func (l *DaemonLogger) GetSocketWriter() (io.Writer, error)

GetSocketWriter retrieves the socketwriter as an io.Writer

func (*DaemonLogger) Println

func (l *DaemonLogger) Println(a interface{})

Println prints to logger's standard writer

func (*DaemonLogger) WriteErr

func (l *DaemonLogger) WriteErr(msg string, status int)

WriteErr directs message and status to http.Error when appropriate

func (*DaemonLogger) WriteSuccess

func (l *DaemonLogger) WriteSuccess(msg string, status int)

WriteSuccess directs status to Header and sets content type when appropriate

type LoggerOptions

type LoggerOptions struct {
	Stdout     io.Writer
	Socket     SocketWriter
	HTTPWriter http.ResponseWriter
	HTTPStream bool
}

LoggerOptions defines configuration for a daemon logger

type MultiWriter

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

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

type SocketWriter

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 WebSocketWriter

type WebSocketWriter struct {
	// contains filtered or unexported fields
}

WebSocketWriter wraps a SocketWriter in an io.Writer

func NewWebSocketTextWriter

func NewWebSocketTextWriter(socket SocketWriter) *WebSocketWriter

NewWebSocketTextWriter returns an io.Writer version of SocketWriter

func (*WebSocketWriter) Close

func (w *WebSocketWriter) Close() error

Close closes the socket writer's websocket.

func (*WebSocketWriter) Write

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL