mirror of
https://github.com/foomo/neosproxy.git
synced 2025-10-16 12:35:39 +00:00
38 lines
587 B
Go
38 lines
587 B
Go
package logging
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func GetDefaultLogEntry() Entry {
|
|
return GetLogEntry(logrus.Fields{})
|
|
}
|
|
|
|
func GetLogEntry(fields logrus.Fields) Entry {
|
|
return &entry{
|
|
stack: Stacks,
|
|
l: Logger.WithFields(fields),
|
|
}
|
|
}
|
|
|
|
func GetFuncLogEntry() Entry {
|
|
if Stacks {
|
|
return GetLogEntry(logrus.Fields{})
|
|
}
|
|
return getFuncLogEntry(1)
|
|
}
|
|
|
|
func GetErrorFromRecovery(r interface{}) (err error) {
|
|
switch x := r.(type) {
|
|
case string:
|
|
err = errors.New(x)
|
|
case error:
|
|
err = x
|
|
default:
|
|
err = errors.New("Unknown panic occurred")
|
|
}
|
|
return
|
|
}
|