def monkey_patch_and_connect_log_observer(crawler, log_observer):
"""Ugly hack to close log file.
Monkey patch log_observer.stop method to close file each time
log observer is closed.
I prefer this to be fixed in Scrapy itself, but as
Scrapy is going to switch to standart python logging soon
this change wouldn't be accepted in preference of merging
new logging sooner.
log_observer.__stop = log_observer.stop
log_observer.stop = types.MethodType(