output

package
v1.9.11 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ElasticSearchConfig added in v1.6.2

type ElasticSearchConfig = elasticsearch.Config

ElasticSearchConfig is the ElasticSearch configuration.

type ElasticSearchDynamicIndexFunc added in v1.6.4

type ElasticSearchDynamicIndexFunc = elasticsearch.DynamicIndexFunc

ElasticSearchDynamicIndexFunc is a function which defines the name of the index and is evaluated at the index time.

type ElasticSearchTagMap added in v1.6.5

type ElasticSearchTagMap = map[string]ElasticSearchTagMapItem

ElasticSearchTagMap is a map of tags to index names.

type ElasticSearchTagMapItem added in v1.6.5

type ElasticSearchTagMapItem struct {
	DynamicIndexFunc ElasticSearchDynamicIndexFunc
	Level            level.Level
}

ElasticSearchTagMapItem is an item of the ElasticSearch tag map.

func NewElasticSearchTagMapItem added in v1.6.5

func NewElasticSearchTagMapItem(
	l level.Level,
	dynamicIndexFunc ElasticSearchDynamicIndexFunc,
) ElasticSearchTagMapItem

NewElasticSearchTagMapItem is a helper to create `ElasticSearchTagMapItem`.

type IOutput

type IOutput interface {
	meta.IMeta

	// String interface.
	String() string

	// GetBuiltinLogger returns the Golang's builtin logger.
	GetBuiltinLogger() *builtin.Builtin

	// SetBuiltinLogger sets the Golang's builtin logger.
	SetBuiltinLogger(builtinLogger *builtin.Builtin) IOutput

	// GetFormatter returns the formatter.
	GetFormatter() formatter.IFormatter

	// SetFormatter sets the formatter.
	SetFormatter(fmtr formatter.IFormatter) IOutput

	// GetMaxLevel returns the max level.
	GetMaxLevel() level.Level

	// SetMaxLevel sets the max level.
	SetMaxLevel(l level.Level) IOutput

	// AddProcessors adds one or more processors.
	AddProcessors(processors ...processor.IProcessor) IOutput

	// GetProcessor returns the registered processor by its name. If not found, will be nil.
	GetProcessor(name string) processor.IProcessor

	// SetProcessors sets one or more processors.
	SetProcessors(processors ...processor.IProcessor) IOutput

	// GetProcessors returns registered processors.
	GetProcessors() []processor.IProcessor

	// GetProcessorsNames returns the names of the registered processors.
	GetProcessorsNames() []string

	// GetWriter returns the writer.
	GetWriter() io.Writer

	// SetWriter sets the writer.
	SetWriter(w io.Writer) IOutput

	// Write write the message to the defined output.
	Write(m message.IMessage) error
}

IOutput specifies what an output does.

func Console

func Console(maxLevel level.Level, processors ...processor.IProcessor) IOutput

Console is a built-in `output` - named `Console`, that writes to `stdout`.

func ElasticSearch added in v1.6.2

func ElasticSearch(
	indexName string,
	esConfig ElasticSearchConfig,
	maxLevel level.Level,
	processors ...processor.IProcessor,
) IOutput

ElasticSearch is a built-in `output` - named `ElasticSearch`, that writes to ElasticSearch.

NOTE: By default, data is JSON-formatted. NOTE: Document ID is automatically generated by hashing the message's content avoiding duplicate documents. NOTE: It's the caller's responsibility to create the index, define its mapping, and settings.

func ElasticSearchWithDynamicIndex added in v1.6.4

func ElasticSearchWithDynamicIndex(
	dynamicIndexFunc ElasticSearchDynamicIndexFunc,
	esConfig ElasticSearchConfig,
	maxLevel level.Level,
	processors ...processor.IProcessor,
) IOutput

ElasticSearchWithDynamicIndex is a built-in `output` - named `ElasticSearchWithDynamicIndex` that writes to ElasticSearch. It allows to define a function that returns the index name to be used, evaluated at the index time.

NOTE: By default, data is JSON-formatted. NOTE: Document ID is automatically generated by hashing the message's content avoiding duplicate documents. NOTE: It's the caller's responsibility to create the index, define its mapping, and settings.

func ElasticSearchWithTagMap added in v1.6.5

func ElasticSearchWithTagMap(
	tagMap ElasticSearchTagMap,
	esConfig ElasticSearchConfig,
	processors ...processor.IProcessor,
) []IOutput

ElasticSearchWithTagMap is a built-in `output` - named `ElasticSearchWithTagMap-{tag}` that writes to ElasticSearch. It allows to define a map of tags and indexes. The index name is a function which defines the name of the index and is evaluated at the index time.

IT'S THE CALLER'S RESPONSIBILITY TO DEFINE A CATCH-ALL INDEX - IF DESIRED. TO ACHIEVE THIS, USE `*` AS THE TAG NAME.

NOTE: By default, data is JSON-formatted. NOTE: Document ID is automatically generated by hashing the message's content avoiding duplicate documents. NOTE: It's the caller's responsibility to create the index, define its mapping, and settings.

func File

func File(path string, maxLevel level.Level, processors ...processor.IProcessor) IOutput

File is a built-in `output` - named `File`, that writes to the specified file.

NOTE: If the common used "-" is used, it will behave as a Console writing to stdout. NOTE: If no path is provided, it'll create one in the OS's temp directory. NOTE: If the dir and/or file does not exist, it will be created.

func FileBased

func FileBased(
	name string,
	maxLevel level.Level,
	writer io.Writer,
	processors ...processor.IProcessor,
) IOutput

FileBased is a built-in `output`, that writes to the specified file.

func New

func New(name string,
	maxLevel level.Level,
	w io.Writer,
	processors ...processor.IProcessor,
) IOutput

New is the Output factory.

func SafeBuffer

func SafeBuffer(maxLevel level.Level, processors ...processor.IProcessor) (*safebuffer.Buffer, IOutput)

SafeBuffer is a built-in `output` - named `Buffer`, that writes to the buffer.

func StdErr

func StdErr(processors ...processor.IProcessor) IOutput

StdErr is a built-in `output` - named `StdErr`, that only writes to `stderr` message @ Error level.

Jump to

Keyboard shortcuts

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