logging

package
v0.0.0-...-3220a8e Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Unlicense Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_APPNAME = "unconfigured-app"
View Source
const DEFAULT_ENVIRONMENT = "unconfigured"
View Source
const DEFAULT_LEVEL = logrus.InfoLevel

Variables

View Source
var AppName string
View Source
var Environment string
View Source
var HostName string

Functions

func AddToContext

func AddToContext(c context.Context, label string, value interface{}) context.Context

AddToContext adds a value to the context Any future logging using this context will include this field with the given label

func Debug

func Debug(args ...interface{})

Debug logs a debug message

func Error

func Error(args ...interface{})

Error logs an error message

func HeadersFromContext

func HeadersFromContext(c context.Context, headerMap map[string]string) map[string][]string

HeadersFromContext accepts a map[string]string with context keys as keys and header names as values. It returns a map[string]string that can be used to set headers on new requests or reaponses

func Info

func Info(args ...interface{})

Info logs an info message

func New

func New() *logWriter

Types

type Logger

type Logger interface {
	WithError(err error) Logger
	Error(args ...interface{})
	WithField(key string, value interface{}) Logger
	WithFields(map[string]interface{}) Logger
	Info(args ...interface{})
}

func WithError

func WithError(err error) Logger

WithError returns a reusable logger interface decorated with an "error=<err>" tag

func WithField

func WithField(key string, value interface{}) Logger

WithField returns a reusable logger interface decorated with "key=value" tag

func WithFields

func WithFields(fields map[string]interface{}) Logger

WithFields returns a reusable logger interface decorated with any number of "key=value" tags

Jump to

Keyboard shortcuts

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