package funcs import ( "context" "github.com/jackc/pgx/v4" "github.com/phuslu/log" ) //PGXLogger is an struct to intergrate the Logger Interface of pgx type PGXLogger struct{} // Log sends the logging data to phuslu/log func (PGXLogger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]interface{}) { var entry *log.Entry switch level { case pgx.LogLevelDebug: entry = log.Debug() case pgx.LogLevelError: entry = log.Error() case pgx.LogLevelInfo: entry = log.Info() case pgx.LogLevelTrace: entry = log.Trace() case pgx.LogLevelWarn: entry = log.Warn() default: entry = log.Info() } for key, value := range data { entry = entry.Interface(key, value) } entry.Msg(msg) } var _ pgx.Logger = PGXLogger{}