monitor

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const TokenF = "token"

TokenF is a token field name that will be stripped from logs in production mode.

View Source
const ValueMask = "****"

ValueMask is what replaces sensitive fields contents in logs.

Variables

View Source
var IgnoredExceptions = []string{
	"account identificator required",
}
View Source
var Logger = logrus.New()

Logger is a global instance of logrus object.

Functions

func CaptureException

func CaptureException(err error, params ...map[string]string)

CaptureException sends to Sentry general exception info with some extra provided detail (like user email, claim url etc)

func CaptureRequestError added in v0.9.1

func CaptureRequestError(err error, r *http.Request, w http.ResponseWriter, params ...map[string]interface{})

func ErrorLoggingMiddleware added in v0.9.1

func ErrorLoggingMiddleware(next http.Handler) http.Handler

ErrorLoggingMiddleware intercepts panics and regular error responses from http handlers, handles them in a graceful way, logs and sends them to Sentry

func LogCachedQuery

func LogCachedQuery(method string)

LogCachedQuery logs a cache hit for a given method

func LogFailedQuery

func LogFailedQuery(method string, query interface{}, errorResponse interface{})

LogFailedQuery takes a method name, query params, response error object and logs it

func LogSuccessfulQuery

func LogSuccessfulQuery(method string, time float64, params interface{}, response interface{})

LogSuccessfulQuery takes a remote method name, execution time and params and logs it

func SetupLogging

func SetupLogging()

SetupLogging initializes and sets a few parameters for the logging subsystem.

Types

type F

type F map[string]interface{}

F can be supplied to ModuleLogger's Log function for providing additional log context.

type ModuleLogger

type ModuleLogger struct {
	ModuleName string
	Logger     *logrus.Logger
	Level      logrus.Level
}

ModuleLogger contains module-specific logger details.

func NewModuleLogger

func NewModuleLogger(moduleName string) ModuleLogger

NewModuleLogger creates a new ModuleLogger instance carrying module name for later `Log()` calls.

func (ModuleLogger) Disable added in v0.9.1

func (l ModuleLogger) Disable()

Disable turns off logging output for this module logger

func (ModuleLogger) Log

func (l ModuleLogger) Log() *logrus.Entry

Log returns a new log entry for the module which can be called upon with a corresponding logLevel. Example:

Log().Info("query error")

func (ModuleLogger) LogF

func (l ModuleLogger) LogF(fields F) *logrus.Entry

LogF is a deprecated method, an equivalent WithFields/WithField should be used.

func (ModuleLogger) WithField added in v0.11.0

func (l ModuleLogger) WithField(key string, value interface{}) *logrus.Entry

WithField is a shortcut for when a single log entry field is needed.

func (ModuleLogger) WithFields added in v0.11.0

func (l ModuleLogger) WithFields(fields F) *logrus.Entry

WithFields returns a new log entry containing additional info provided by fields, which can be called upon with a corresponding logLevel. Example:

logger.WithFields(F{"query": "..."}).Info("query error")

type ProxyLogger added in v0.7.0

type ProxyLogger struct {
	Level logrus.Level
	// contains filtered or unexported fields
}

func NewProxyLogger added in v0.7.0

func NewProxyLogger() *ProxyLogger

func (*ProxyLogger) Error added in v0.7.0

func (l *ProxyLogger) Error(message string)

func (*ProxyLogger) Errorf added in v0.7.0

func (l *ProxyLogger) Errorf(message string, args ...interface{})

func (*ProxyLogger) LogFailedQuery added in v0.7.0

func (l *ProxyLogger) LogFailedQuery(method string, params interface{}, errorResponse interface{})

func (*ProxyLogger) LogSuccessfulQuery added in v0.7.0

func (l *ProxyLogger) LogSuccessfulQuery(method string, time float64, params interface{}, response interface{})

func (*ProxyLogger) Logger added in v0.7.0

func (l *ProxyLogger) Logger() *logrus.Logger

type QueryMonitor added in v0.7.0

type QueryMonitor interface {
	LogSuccessfulQuery(method string, time float64, params interface{}, response interface{})
	LogFailedQuery(method string, params interface{}, errorResponse interface{})
	Error(message string)
	Errorf(message string, args ...interface{})
	Logger() *logrus.Logger
}

Jump to

Keyboard shortcuts

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