logging

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

logging implements a logs reporter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Destinations represents the list of logging destinations.
	Destinations []*LogDestinationConfig `yaml:"destinations"`

	// Context represents user-defined context key/values to be injected into log records.
	Context map[string]string `yaml:"context"`

	// ReportErrors represents a flag indicating whether to automatically send error-level and higher
	// log messages to the errors reporter (the errors reporter has to be configured).
	ReportErrors bool `yaml:"report_errors"`

	// Debug represents a flags indicating whether to enable internal reporter activity logging.
	// This is mainly for debug purposes.
	Debug bool `yaml:"debug"`
}

Config represents a logging reporter configuration.

type LogDestinationConfig

type LogDestinationConfig struct {
	// Type represents the destination type (file|console|syslog).
	Type string `yaml:"type"`

	// Destination represents the log destination depending on the type:
	// - For type "file", is must be a filesystem path
	// - For "console", it is ignored
	// - For type "syslog", it can be either empty (local syslog) or a net.Dial compatible string for remote syslog
	Destination string `yaml:"destination"`

	// Level represents the highest message severity level to report (crit..debug).
	Level string `yaml:"level"`

	// Format represents the format to apply to logged messages (plain|json).
	Format string `yaml:"format"`
}

LogDestinationConfig represents a logging reporter destination.

type Reporter

type Reporter struct {
	*debug.D
	// contains filtered or unexported fields
}

Reporter represents a logging reporter instance.

func New

func New(config *Config) (*Reporter, error)

New returns a new logging reporter instance.

func (*Reporter) Crit

func (r *Reporter) Crit(msg string, ctx ...interface{})

Crit logs a message with a "critical" severity level.

func (*Reporter) Debug

func (r *Reporter) Debug(msg string, ctx ...interface{})

Debug logs a message with a "debug" severity level.

func (*Reporter) Error

func (r *Reporter) Error(msg string, ctx ...interface{})

Error logs a message with an "error" severity level.

func (*Reporter) Handler

func (r *Reporter) Handler() log15.Handler

Handler returns the logging reporter's log15.Handler.

func (*Reporter) Info

func (r *Reporter) Info(msg string, ctx ...interface{})

Info logs a message with an "info" severity level.

func (*Reporter) SetHandler

func (r *Reporter) SetHandler(h log15.Handler)

SetHandler sets the logging reporter's log15.Handler.

func (*Reporter) Start

func (r *Reporter) Start(_ context.Context) error

Start is a no-op operation.

func (*Reporter) Stop

func (r *Reporter) Stop(_ context.Context) error

Stop is a no-op operation.

func (*Reporter) Warn

func (r *Reporter) Warn(msg string, ctx ...interface{})

Warn logs a message with a "warning" severity level.

Jump to

Keyboard shortcuts

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