logging

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessLogCookiesBlacklist = []string{}

The of cookies which should not be logged

View Source
var CorrelationIdHeader = "X-Correlation-Id"
View Source
var LifecycleEnvVars = []string{"BUILD_NUMBER", "BUILD_HASH", "BUILD_DATE"}
View Source
var Logger *logrus.Logger
View Source
var UserCorrelationCookie = ""

Functions

func Access

func Access(r *http.Request, start time.Time, statusCode int)

Access logs an access entry with call duration and status code

func AccessError

func AccessError(r *http.Request, start time.Time, err error)

AccessError logs an error while accessing

func Application

func Application(h http.Header) *logrus.Entry

Return a log entry for application logs, prefilled with the correlation ids out of the supplied request.

func Cacheinfo

func Cacheinfo(url string, hit bool)

Cacheinfo logs the hit information a accessing a ressource

func Call

func Call(r *http.Request, resp *http.Response, start time.Time, err error)

Call logs the result of an outgoing call

func EnsureCorrelationId

func EnsureCorrelationId(r *http.Request) string

EnsureCorrelationId returns the correlation from of the request. If the request does not have a correlation id, one will be generated and set to the request.

func GetCorrelationId

func GetCorrelationId(h http.Header) string

GetCorrelationId returns the correlation from of the request.

func GetUserCorrelationId

func GetUserCorrelationId(h http.Header) string

GetCorrelationId returns the users correlation id of the headers.

func LifecycleStart

func LifecycleStart(appName string, args interface{})

LifecycleStart logs the start of an application with the configuration struct or map as paramter.

func LifecycleStop

func LifecycleStop(appName string, signal os.Signal, err error)

LifecycleStop logs the stop of an application

func ServerClosed

func ServerClosed(appName string)

LifecycleStop logs the stop of an application

func Set

func Set(level string, textLogging bool) error

Set creates a new Logger with the matching specification

Types

type LogMiddleware

type LogMiddleware struct {
	Next http.Handler
}

func NewLogMiddleware

func NewLogMiddleware(next http.Handler) *LogMiddleware

func (*LogMiddleware) ServeHTTP

func (mw *LogMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LogstashFormatter

type LogstashFormatter struct {
	Type string // if not empty use for logstash type field.

	// TimestampFormat sets the format used for timestamps.
	TimestampFormat string
}

Formatter generates json in logstash format. Logstash site: http://logstash.net/

func (*LogstashFormatter) Format

func (f *LogstashFormatter) Format(entry *logrus.Entry) ([]byte, error)

func (*LogstashFormatter) FormatWithPrefix

func (f *LogstashFormatter) FormatWithPrefix(entry *logrus.Entry, prefix string) ([]byte, error)

Jump to

Keyboard shortcuts

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