Fenpaws
b6d0f4d63f
Better and more extensive logging with proper logging levels, also new env variables are created to control those. Reviewed-on: anthrove/e621-to-graph#16 Reviewed-by: Lennard Brinkhaus <lennard.brinkhaus@noreply.localhost> Co-authored-by: Fenpaws <soxx@fenpa.ws> Co-committed-by: Fenpaws <soxx@fenpa.ws>
46 lines
1023 B
Go
46 lines
1023 B
Go
package neo4j
|
|
|
|
import (
|
|
"fmt"
|
|
neo4jLog "github.com/neo4j/neo4j-go-driver/v5/neo4j/log"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type neo4jLogger struct {
|
|
neo4jDebug bool
|
|
}
|
|
|
|
func NewNeo4jLogger(neo4jDebug bool) neo4jLog.Logger {
|
|
return &neo4jLogger{neo4jDebug: neo4jDebug}
|
|
}
|
|
|
|
func (n neo4jLogger) Error(name string, id string, err error) {
|
|
log.WithFields(log.Fields{
|
|
"name": name,
|
|
"id": id,
|
|
}).Errorf("neo4j: %s", err)
|
|
}
|
|
|
|
func (n neo4jLogger) Warnf(name string, id string, msg string, args ...any) {
|
|
log.WithFields(log.Fields{
|
|
"name": name,
|
|
"id": id,
|
|
}).Warnf("neo4j: %v", fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
func (n neo4jLogger) Infof(name string, id string, msg string, args ...any) {
|
|
log.WithFields(log.Fields{
|
|
"name": name,
|
|
"id": id,
|
|
}).Infof("neo4j: %v", fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
func (n neo4jLogger) Debugf(name string, id string, msg string, args ...any) {
|
|
if n.neo4jDebug {
|
|
log.WithFields(log.Fields{
|
|
"name": name,
|
|
"id": id,
|
|
}).Debugf("neo4j: %v", fmt.Sprintf(msg, args...))
|
|
}
|
|
}
|