Middleware for sql logs