Documentation ¶
Index ¶
- Constants
- Variables
- func CaptureException(err error, params ...map[string]string)
- func CaptureRequestError(err error, r *http.Request, w http.ResponseWriter, ...)
- func ErrorLoggingMiddleware(next http.Handler) http.Handler
- func LogCachedQuery(method string)
- func LogFailedQuery(method string, query interface{}, errorResponse interface{})
- func LogSuccessfulQuery(method string, time float64, params interface{}, response interface{})
- func SetupLogging()
- type F
- type ModuleLogger
- type ProxyLogger
- func (l *ProxyLogger) Error(message string)
- func (l *ProxyLogger) Errorf(message string, args ...interface{})
- func (l *ProxyLogger) LogFailedQuery(method string, params interface{}, errorResponse interface{})
- func (l *ProxyLogger) LogSuccessfulQuery(method string, time float64, params interface{}, response interface{})
- func (l *ProxyLogger) Logger() *logrus.Logger
- type QueryMonitor
Constants ¶
const TokenF = "token"
TokenF is a token field name that will be stripped from logs in production mode.
const ValueMask = "****"
ValueMask is what replaces sensitive fields contents in logs.
Variables ¶
var IgnoredExceptions = []string{
"account identificator required",
}
var Logger = logrus.New()
Logger is a global instance of logrus object.
Functions ¶
func CaptureException ¶
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 ErrorLoggingMiddleware ¶ added in v0.9.1
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 ¶
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 ¶
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
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