47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package internal
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
neo4jLog "github.com/neo4j/neo4j-go-driver/v5/neo4j/log"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type graphLogger struct {
|
|
graphDebug bool
|
|
}
|
|
|
|
func NewGraphLogger(graphDebug bool) neo4jLog.Logger {
|
|
return &graphLogger{graphDebug: graphDebug}
|
|
}
|
|
|
|
func (n graphLogger) Error(name string, id string, err error) {
|
|
log.WithFields(log.Fields{
|
|
"name": name,
|
|
"id": id,
|
|
}).Errorf("graph: %s", err)
|
|
}
|
|
|
|
func (n graphLogger) Warnf(name string, id string, msg string, args ...any) {
|
|
log.WithFields(log.Fields{
|
|
"name": name,
|
|
"id": id,
|
|
}).Warnf("graph: %v", fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
func (n graphLogger) Infof(name string, id string, msg string, args ...any) {
|
|
log.WithFields(log.Fields{
|
|
"name": name,
|
|
"id": id,
|
|
}).Infof("graph: %v", fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
func (n graphLogger) Debugf(name string, id string, msg string, args ...any) {
|
|
if n.graphDebug {
|
|
log.WithFields(log.Fields{
|
|
"name": name,
|
|
"id": id,
|
|
}).Debugf("graph: %v", fmt.Sprintf(msg, args...))
|
|
}
|
|
}
|