Documentation
¶
Overview ¶
Package logrus represents implementations the interface logging.Log. The package is focused on the GELF Payload Specification logging format (http://docs.graylog.org/en/2.4/pages/gelf.html). Package implements adding to log the "timestamp" field, and gives the opportunity to specify fields: - "level"; - "short_message". Adding marked fields is implemented in "github.com/sirupsen/logrus", the capabilities of which are implemented in the package.
Index ¶
- Constants
- func New(breaker chan context.Context, level string, outputs ...string) (logging.Logger, error)
- type ContextLogger
- func (cl *ContextLogger) AddHooks(hooks ...interface{}) error
- func (cl *ContextLogger) FromContext(ctx context.Context) logging.Entry
- func (cl *ContextLogger) GetValues() logging.Values
- func (cl *ContextLogger) GracefulFatal(ctx context.Context)
- func (cl *ContextLogger) NewContext(ctx context.Context) context.Context
- func (cl *ContextLogger) TruncateToMaxValueLength(value []byte) []byte
- func (cl *ContextLogger) WithValues(v logging.Values) logging.Entry
Constants ¶
const ( // DebugLevel - determines the level of logging "debug". DebugLevel string = "debug" // InfoLevel - determines the level of logging "info". InfoLevel string = "info" // WarnLevel - determines the level of logging "warning". WarnLevel string = "warning" // ErrorLevel - determines the level of logging "error". ErrorLevel string = "error" // FatalLevel - determines the level of logging "fatal". FatalLevel string = "fatal" // PanicLevel - determines the level of logging "panic". PanicLevel string = "panic" )
const GraylogMaxLenValue int = 31000
GraylogMaxLenValue - defines the maximum length of a value.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New is a ContextLogger constructor. New takes argument outputs. Outputs is an optional argument in the slice the outputs to the files of the additional log. - If outputs is empty, then only std output on /dev/stderr is used. - If outputs is not empty, then values of the slice is used to output the log to an additional files along with the std output.
Types ¶
type ContextLogger ¶
ContextLogger implements log.Log.
func (*ContextLogger) AddHooks ¶
func (cl *ContextLogger) AddHooks(hooks ...interface{}) error
AddHooks adds hooks from the cut of the hooks in the argument. If the hook does not match the interface log.Hook, returns an error.
func (*ContextLogger) FromContext ¶
func (cl *ContextLogger) FromContext(ctx context.Context) logging.Entry
FromContext returns the Entry stored in a context, or nil if there isn't one.
func (*ContextLogger) GetValues ¶
func (cl *ContextLogger) GetValues() logging.Values
GetValues provides the current context of the instance.
func (*ContextLogger) GracefulFatal ¶
func (cl *ContextLogger) GracefulFatal(ctx context.Context)
GracefulFatal performs a soft fatal telling the fatal signal to the main application.
func (*ContextLogger) NewContext ¶
func (cl *ContextLogger) NewContext(ctx context.Context) context.Context
NewContext returns the new context with entry.
func (*ContextLogger) TruncateToMaxValueLength ¶
func (cl *ContextLogger) TruncateToMaxValueLength(value []byte) []byte
TruncateToMaxValueLength returns a value optimized for the maximum supported length.
func (*ContextLogger) WithValues ¶
func (cl *ContextLogger) WithValues(v logging.Values) logging.Entry
WithValues wraps the logging.Values in log.Values and returns an instance of the entry in the form of interface logging.Entry. Provides an instance of an entry with primary implementation of fields.