Documentation ¶
Overview ¶
Package logging provides utilities for logging.
Index ¶
- Variables
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func GetLogEntry(r *http.Request) logrus.FieldLogger
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func LogEntrySetField(r *http.Request, key string, value interface{})
- func LogEntrySetFields(r *http.Request, fields map[string]interface{})
- func MockSharedLoggerHook() (hook *test.Hook, restoreFunc func())
- func NewRawDBLogger(logger DBLogger, rawLogMode bool) instrumentedsql.Logger
- func NewStructuredLogger() func(next http.Handler) http.Handler
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func ResetShared()
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func WithField(key string, value interface{}) *logrus.Entry
- func WithFields(fields map[string]interface{}) *logrus.Entry
- type DBLogger
- type Logger
- type StructuredDBLogger
- type StructuredLogger
- type StructuredLoggerEntry
Constants ¶
This section is empty.
Variables ¶
SharedLogger is the global scope logger It should not be used directly by other packages (except for testing) which should prefer shorthands functions.
Functions ¶
func Debug ¶
func Debug(args ...interface{})
Debug logs a message at level Debug on the shared logger.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs a message at level Debug on the shared logger.
func Error ¶
func Error(args ...interface{})
Error logs a message at level Error on the shared logger.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs a message at level Error on the shared logger.
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func GetLogEntry ¶
func GetLogEntry(r *http.Request) logrus.FieldLogger
GetLogEntry return the request scoped logrus.FieldLogger. noinspection GoUnusedExportedFunction.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs a message at level Info on the shared logger.
func LogEntrySetField ¶
LogEntrySetField adds a field to the request scoped logrus.FieldLogger. noinspection GoUnusedExportedFunction.
func LogEntrySetFields ¶
LogEntrySetFields adds multiple fields to the request scoped logrus.FieldLogger. noinspection GoUnusedExportedFunction.
func MockSharedLoggerHook ¶
MockSharedLoggerHook set a null/mock logger as shared and return the hook and the function restoring the initial logger.
func NewRawDBLogger ¶
func NewRawDBLogger(logger DBLogger, rawLogMode bool) instrumentedsql.Logger
NewRawDBLogger returns a logger for raw database actions using an existing dblogger and rawLogMode setting.
func NewStructuredLogger ¶
NewStructuredLogger implements a custom structured logger using the global one.
func Panic ¶
func Panic(args ...interface{})
Panic logs a message at level Panic on the shared logger.
func Panicf ¶
func Panicf(format string, args ...interface{})
Panicf logs a message at level Panic on the shared logger.
func ResetShared ¶
func ResetShared()
ResetShared reset the global logger to its default settings before its configuration.
func Warnf ¶
func Warnf(format string, args ...interface{})
Warnf logs a message at level Warn on the shared logger.
func WithField ¶
WithField creates an entry from the standard logger and adds a field to it. If you want multiple fields, use `WithFields`.
Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.
func WithFields ¶
WithFields creates an entry from the standard logger and adds multiple fields to it. This is simply a helper for `WithField`, invoking it once for each field.
Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.
Types ¶
type DBLogger ¶
type DBLogger interface {
Print(v ...interface{})
}
DBLogger is the logger interface for the DB logs.
type Logger ¶
Logger is wrapper around a logger and keeping the logging config so that it can be reused by other loggers.
func NewMockLogger ¶
NewMockLogger creates a null/mock logger and return the logger and the hook.
type StructuredDBLogger ¶
type StructuredDBLogger struct {
// contains filtered or unexported fields
}
StructuredDBLogger is a database structured logger.
func NewStructuredDBLogger ¶
func NewStructuredDBLogger(logger *logrus.Logger) *StructuredDBLogger
NewStructuredDBLogger created a database structured logger.
func (*StructuredDBLogger) Print ¶
func (l *StructuredDBLogger) Print(values ...interface{})
Print defines how StructuredDBLogger print log entries. values: 0: level, 1: source file, 2: duration in ns, 3: query, 4: slice of parameters, 5: rows affected or returned
type StructuredLogger ¶
StructuredLogger is a structured logrus Logger.
func (*StructuredLogger) NewLogEntry ¶
func (l *StructuredLogger) NewLogEntry(r *http.Request) middleware.LogEntry
NewLogEntry sets default request log fields.
type StructuredLoggerEntry ¶
type StructuredLoggerEntry struct {
Logger logrus.FieldLogger
}
StructuredLoggerEntry is a logrus.FieldLogger.
func (*StructuredLoggerEntry) Panic ¶
func (l *StructuredLoggerEntry) Panic(v interface{}, stack []byte)
Panic prints stack trace.