logging

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldAction          = "action"
	FieldTransID         = "transactionID"
	FieldURL             = "url"
	FieldHost            = "host"
	FieldHTTPMethod      = "httpMethod"
	FieldRPCMethod       = "rpcMethod"
	FieldRequest         = "request"
	FieldResponseCode    = "ResponseCode"
	FieldService         = "service"
	FieldRequestHandler  = "requestType"
	FieldClientAppUserID = "ClientAppUserID"
)
View Source
const (
	LevelInfo  = "Info"
	LevelWarn  = "Warn"
	LevelError = "Error"
	LevelFatal = "Fatal"
)

Variables

This section is empty.

Functions

func LogFatalOnError

func LogFatalOnError(lg Logger, err error, action string)

func LogWarnOnError

func LogWarnOnError(lg Logger, err error, action string)

func SetEntryLoggerFunc

func SetEntryLoggerFunc(loggerFunc EntryLoggerFunc)

Types

type Entry

type Entry struct {
	Fields  map[string]interface{}
	Level   string
	Payload string
	Time    time.Time
}

type EntryLogWrapper

type EntryLogWrapper struct {
	Fields  map[string]interface{}
	HTTPReq *http.Request
}

EntryLogWrapper implements the Logger interface by using an EntryLoggerFunc to print out the final log. To use an entry logger, add a blank identifier import e.g. for the standard logger use:

_ "github.com/tomogoma/authms/logging/standard"

for the purpose of its side effects.

func (*EntryLogWrapper) Error

func (lg *EntryLogWrapper) Error(args ...interface{})

func (*EntryLogWrapper) Errorf

func (lg *EntryLogWrapper) Errorf(f string, args ...interface{})

func (*EntryLogWrapper) Fatal

func (lg *EntryLogWrapper) Fatal(args ...interface{})

func (*EntryLogWrapper) Fatalf

func (lg *EntryLogWrapper) Fatalf(f string, args ...interface{})

func (*EntryLogWrapper) Info

func (lg *EntryLogWrapper) Info(args ...interface{})

func (*EntryLogWrapper) Infof

func (lg *EntryLogWrapper) Infof(f string, args ...interface{})

func (*EntryLogWrapper) Warn

func (lg *EntryLogWrapper) Warn(args ...interface{})

func (*EntryLogWrapper) Warnf

func (lg *EntryLogWrapper) Warnf(f string, args ...interface{})

func (*EntryLogWrapper) WithField

func (lg *EntryLogWrapper) WithField(k string, v interface{}) Logger

func (*EntryLogWrapper) WithFields

func (lg *EntryLogWrapper) WithFields(f map[string]interface{}) Logger

func (*EntryLogWrapper) WithHTTPRequest

func (lg *EntryLogWrapper) WithHTTPRequest(r *http.Request) Logger

type EntryLogger

type EntryLogger interface {
	Log(Entry)
}

type EntryLoggerFunc

type EntryLoggerFunc func(entry Entry)

type Logger

type Logger interface {
	WithHTTPRequest(r *http.Request) Logger
	WithFields(map[string]interface{}) Logger
	WithField(string, interface{}) Logger
	Infof(fmt string, args ...interface{})
	Warnf(fmt string, args ...interface{})
	Errorf(fmt string, args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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