logger

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: MIT Imports: 3 Imported by: 13

README

Golang logger package

GoDoc

This is a proxy for github.com/Sirupsen/logrus with some additions like functional options and logging to file.

Documentation

Overview

Package logger incapsulates logger logic This is a proxy for github.com/Sirupsen/logrus with some additions like functional options and logging to file

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dest

func Dest(s string) func(logger *Log) error

Dest sets log destionation (STDERR if empty and file if given)

func Disable

func Disable(logger *Log) error

Disable turns logging off

func Level

func Level(s string) func(logger *Log) error

Level sets log level from a string value (debug/info/warn/error/fatal/panic)

func TimeStamp

func TimeStamp(logger *Log) error

TimeStamp adds timestamp in log output

Types

type Fields

type Fields map[string]interface{}

Fields type, used to pass to `WithFields`.

type Flags

type Flags struct {
	Dest  string `long:"log_dest"  description:"Log destination (STDERR)"`
	Level string `long:"log_level" description:"Log level [warn|info|debug]" default:"warn"`
}

Flags is a package flags sample in form ready for use with github.com/jessevdk/go-flags

type Log

type Log struct {
	*logrus.Entry
	// contains filtered or unexported fields
}

Log is a copy of logrus.Entry plus, when logging to file used, its filehandle.

func New

func New(options ...func(logger *Log) error) (*Log, error)

New creates a logger object Configuration should be set via functional options

func (*Log) Close

func (logger *Log) Close() error

Close closes filehandle if it was used

func (*Log) WithField

func (logger *Log) WithField(key string, value interface{}) *Log

WithField add a var/value pair into logger output

func (*Log) WithFields

func (logger *Log) WithFields(fields Fields) *Log

WithFields adds a map into logger output

Jump to

Keyboard shortcuts

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