Log errors returned from graphql (#3562)

* Add func methods to logger
* Log errors returned from the graphql interface
* Log authentication
* Log when credentials changed
This commit is contained in:
WithoutPants
2023-04-17 15:27:25 +10:00
committed by GitHub
parent 75f22042b7
commit 32cefea524
8 changed files with 177 additions and 4 deletions

View File

@@ -16,18 +16,23 @@ type LoggerImpl interface {
Trace(args ...interface{})
Tracef(format string, args ...interface{})
TraceFunc(fn func() (string, []interface{}))
Debug(args ...interface{})
Debugf(format string, args ...interface{})
DebugFunc(fn func() (string, []interface{}))
Info(args ...interface{})
Infof(format string, args ...interface{})
InfoFunc(fn func() (string, []interface{}))
Warn(args ...interface{})
Warnf(format string, args ...interface{})
WarnFunc(fn func() (string, []interface{}))
Error(args ...interface{})
Errorf(format string, args ...interface{})
ErrorFunc(fn func() (string, []interface{}))
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
@@ -61,6 +66,14 @@ func Tracef(format string, args ...interface{}) {
}
}
// TraceFunc calls TraceFunc with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func TraceFunc(fn func() (string, []interface{})) {
if Logger != nil {
Logger.TraceFunc(fn)
}
}
// Debug calls Debug with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func Debug(args ...interface{}) {
@@ -77,6 +90,14 @@ func Debugf(format string, args ...interface{}) {
}
}
// DebugFunc calls DebugFunc with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func DebugFunc(fn func() (string, []interface{})) {
if Logger != nil {
Logger.DebugFunc(fn)
}
}
// Info calls Info with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func Info(args ...interface{}) {
@@ -93,6 +114,14 @@ func Infof(format string, args ...interface{}) {
}
}
// InfoFunc calls InfoFunc with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func InfoFunc(fn func() (string, []interface{})) {
if Logger != nil {
Logger.InfoFunc(fn)
}
}
// Warn calls Warn with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func Warn(args ...interface{}) {
@@ -109,6 +138,14 @@ func Warnf(format string, args ...interface{}) {
}
}
// WarnFunc calls WarnFunc with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func WarnFunc(fn func() (string, []interface{})) {
if Logger != nil {
Logger.WarnFunc(fn)
}
}
// Error calls Error with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func Error(args ...interface{}) {
@@ -125,6 +162,14 @@ func Errorf(format string, args ...interface{}) {
}
}
// ErrorFunc calls ErrorFunc with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func ErrorFunc(fn func() (string, []interface{})) {
if Logger != nil {
Logger.ErrorFunc(fn)
}
}
// Fatal calls Fatal with the Logger registered using RegisterLogger.
// If no logger has been registered, then this function is a no-op.
func Fatal(args ...interface{}) {