writer

package
v0.0.0-...-e3a465d Latest Latest
Warning

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

Go to latest
Published: May 24, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

The writer package is an event handler responsible for sending events to a generic IO writer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminal

func IsTerminal(stream interface {
	Fd() uintptr
}) bool

IsTerminal returns whether the given stream (File) is attached to a TTY.

func NewStandardStreamsHandler

func NewStandardStreamsHandler() *standardStreamsHandler

NewStandardStreamsHandler is a convenience function for constructing a new handler which sends to STDOUT/STDERR. If the output is sent to a TTY, the format is formatter.CONSOLE_COLOR_FORMAT. Otherwise it is formatter.CONSOLE_NOCOLOR_FORMAT. The only difference between the two are the use of color escape codes.

Types

type WriterHandler

type WriterHandler struct {
	Output   io.Writer
	Template *template.Template
}

WriterHandler is responsible for converting an event into text using a template, and then sending that text to an io.Writer.

func New

func New(output io.Writer, templateString string) (*WriterHandler, error)

New constructs a new WriterHandler handler. templateString must be a template supported by the sawmill/event/formatter package. If the templateString is empty, the WriterHandler will use sawmill/event/formatter.SIMPLE_FORMAT.

func (*WriterHandler) Event

func (handler *WriterHandler) Event(logEvent *event.Event) error

Event accepts an event, formats it, and writes it to the WriterHandler's Output.

Jump to

Keyboard shortcuts

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