mongodb python middleware log queries