compositelogger

package
v0.0.0-...-03d0fbf Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenOutput

func OpenOutput(location string) (io.Writer, error)

OpenOutput returns an io.Writer for a given location to log. If there is an error, returns the error.

Types

type CompositeLogger

type CompositeLogger struct {
	Logs []*logrus.Logger // array of loggers
}

CompositeLogger is a struct containing an array of loggers.

func NewCompositeLogger

func NewCompositeLogger(logConfigs []*LogConfig) (*CompositeLogger, error)

NewCompositeLogger returns a composite logger for an array of log configurations. If there is an error, returns the error.

func NewDefaultLogger

func NewDefaultLogger() (*CompositeLogger, error)

NewDefaultLogger returns a default composite logger, with stdout/info and stderr/warning. If there is an error, returns the error.

func (*CompositeLogger) Add

func (l *CompositeLogger) Add(location string, format string, level string) error

Add adds a new logger to the composite logger, specified by the parameters. Returns an error, if any.

func (*CompositeLogger) Fatal

func (l *CompositeLogger) Fatal(msg interface{})

Info logs a message with level FATAL to all loggers.

func (*CompositeLogger) Info

func (l *CompositeLogger) Info(msg interface{})

Info logs a message with level INFO to all loggers.

func (*CompositeLogger) InfoWithFields

func (l *CompositeLogger) InfoWithFields(msg interface{}, fields map[string]interface{})

InfoWithFields logs a message with level INFO and a map of fields to all loggers.

func (*CompositeLogger) Warn

func (l *CompositeLogger) Warn(msg interface{})

Info logs a message with level WARN to all loggers.

func (*CompositeLogger) WarnWithFields

func (l *CompositeLogger) WarnWithFields(msg interface{}, fields map[string]interface{})

InfoWithFields logs a message with level WARN and a map of fields to all loggers.

type LogConfig

type LogConfig struct {
	Location string `json:"location" bson:"location" yaml:"location" hcl:"location"` // location of the log
	Level    string `json:"level" bson:"level" yaml:"level" hcl:"level"`             // level of the log: INFO, WARN, DEBUG, etc.
	Format   string `json:"format" bson:"format" yaml:"format" hcl:"format"`         // text or json
}

LogConfig is a struct containing the configuration for an individual log.

Jump to

Keyboard shortcuts

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