Try to fix duplicate log messages in ipython.

It is very annoying to have duplicate log messages in iPython. This is trying to fix that issue. It's not entirely successful.