title: Logging raw queries Generated by MongoEngine
body: <p>I need to log all the queries generated by MongoEngine in my Django app.</p>
  
  <p>I cannot use <code>cursor._query()</code> as I need to log queries for all the MongoEngine Documents.</p>
  
  <p>The logging should be done at app level and not DB level so setting MongoDB profiling level to 2 will not help.</p>
  
  <p>I found this <a href="https://gist.github.com/kesor/1589672" rel="noreferrer">gist</a>, which seems helpful but I fail to understand it.</p>
  
  <p>Is there a simpler way to write a middleware or any other way I can log all the queries.</p>