text

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 4, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package text provides the implementation of an event handler that outputs events in a human-readable format.

Importing this package has the side effect of configuring the default logger to use a text handler if stdout is a terminal.

Index

Constants

View Source
const DefaultTimeFormat = "2006-01-02 15:04:05.000"

DefaultTimeFormat is the default time format set on Handler.

Variables

View Source
var DefaultPrefix string

DefaultPrefix is used by the default handler configured when the program's standard output is a terminal.

The value is "program-name[pid]: "

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Output       io.Writer      // writer receiving the formatted events
	Prefix       string         // written at the beginning of each formatted event
	TimeFormat   string         // format used for the event's time
	TimeLocation *time.Location // location to output the event time in
	EnableArgs   bool           // output detailes of each args in the events
	// contains filtered or unexported fields
}

Handler is an event handler which format events in a human-readable format and writes them to its output.

It is safe to use a handler concurrently from multiple goroutines.

func NewHandler

func NewHandler(prefix string, output io.Writer) *Handler

NewHandler creates a new handler which writes to output with a prefix on each line.

func (*Handler) HandleEvent

func (h *Handler) HandleEvent(e *events.Event)

HandleEvent satisfies the events.Handler interface.

Jump to

Keyboard shortcuts

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