Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/util/log/error.go
akuma06 9586f1e731 Rearranged Files
Configurations are separated in files in the folder config
Connection to database by a package to import when needed
Models will be in a model package for better maintenance
Services access to the models
Utils are tools or functions that can be used anywhere
main.go cleaned a bit and other files modifications are there for the above modifications
2017-05-05 14:20:51 +02:00

29 lignes
855 o
Go

package log
import (
"fmt"
"github.com/Sirupsen/logrus"
"runtime"
)
// CheckError check error and return true if error is nil and return false if error is not nil.
func CheckError(err error) bool {
return CheckErrorWithMessage(err, "")
}
// CheckErrorWithMessage check error with message and log messages with stack. And then return true if error is nil and return false if error is not nil.
func CheckErrorWithMessage(err error, msg string, args ...interface{}) bool {
if err != nil {
var stack [4096]byte
runtime.Stack(stack[:], false)
// logrus.Errorf(msg, args)
if len(args) == 0 {
logrus.Error(msg + fmt.Sprintf("%q\n%s\n", err, stack[:]))
} else {
logrus.Error(fmt.Sprintf(msg, args...) + fmt.Sprintf("%q\n%s\n", err, stack[:]))
}
// logrus.Printf(msg+"\n%q\n%s\n",args, err, stack[:])
return false
}
return true
}