jsonprinter

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugJSONLogger

type DebugJSONLogger interface {
	JSONLogger
	EnableDebugLogging(bool)
}

DebugJSONLogger allowed you to also toggle debug messages on and off while also pulling in JSONLogger

type JSONLogger

type JSONLogger interface {
	EnablePrettyPrint(bool)
	EnableAuditMode(bool)
	EnableHumanTimestamps(bool)
	AddDecoration(map[string]interface{})
	AddMutator(Mutator)
	OverridePrinter(overrides.Overrider)
	Send(*jsonmessage.JSONMessage)
	Flush() chan bool
}

JSONLogger is a logger that implements the functions of this package

type JSONPrinter

type JSONPrinter struct {
	FinishedChan chan bool
	// contains filtered or unexported fields
}

JSONPrinter consumes JSON Logs and sends them to the current output

func New

func New(buffer uint) *JSONPrinter

New created a empty JSON Printer and starts the printer ready for messages.

func (*JSONPrinter) AddDecoration added in v0.2.0

func (j *JSONPrinter) AddDecoration(decorator map[string]interface{})

AddDecoration is used to add default keys with corresponding values. These are added to ALL JSONMessages that are sent via this printer.

func (*JSONPrinter) AddMutator added in v0.3.0

func (j *JSONPrinter) AddMutator(m Mutator)

AddMutator adds in the supplied mutator to the list of mutations that get called on the log. Beware, here lay dragons. Mutations to logs let you change the log message before they get sent to the printers buffer. If a mutation fails the log message will be discarded as there is no was to know how to fix it. It is up to the developer to make sure that the message is not damaged when the mutator is completed.

func (*JSONPrinter) EnableAuditMode

func (j *JSONPrinter) EnableAuditMode(toggle bool)

EnableAuditMode will cause the logger to slow down if it us unable to process logs fast enough. Consider using this with a high buffer count.

func (*JSONPrinter) EnableDebugLogging

func (j *JSONPrinter) EnableDebugLogging(toggle bool)

EnableDebugLogging signals the Logger to print debug messages.

func (*JSONPrinter) EnableHumanTimestamps added in v0.2.0

func (j *JSONPrinter) EnableHumanTimestamps(toggle bool)

EnableHumanTimestamps will instruct the printer to tell the JSONMessages that get passed in to try set a human readable timestamp.

func (*JSONPrinter) EnablePrettyPrint

func (j *JSONPrinter) EnablePrettyPrint(toggle bool)

EnablePrettyPrint signals the Logger to print human readable messages.

func (*JSONPrinter) Flush

func (j *JSONPrinter) Flush() chan bool

Flush stops the logger from consuming more messages. Flush returns a chan bool to tell you when all messages have been printed. The channel will be closed once all messages have been flushed.

func (*JSONPrinter) OverridePrinter

func (j *JSONPrinter) OverridePrinter(override overrides.Overrider)

OverridePrinter is used to insert your own function for hijacking the message on the way to the console. This allows you to push the log message to where ever you want.

func (*JSONPrinter) Send

func (j *JSONPrinter) Send(msg *jsonmessage.JSONMessage)

Send takes a pointer to a JSONMessage and send it to the printer. If the logger is already shutdown then it will just silently consume the message.

type Mutator added in v0.3.0

type Mutator interface {
	Mutate(*jsonmessage.JSONMessage) bool
}

Mutator is used to change a message before it gets sent into the printers buffer. The returned bool must indicate to the printer if it should carry on proccessing the log message. If your mutation doesn't work consider creating a new json message and replacing the data in the pointer and sending that instead.

Jump to

Keyboard shortcuts

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