So I was playing around with Google's Tensorflow library they published yesterday and encountered an annoying bug that keeps biting me.
What I did was setup the python logging functions as I usually do, and the result was that, if I import the tensorflow library, all messages in the console started doubling. Interestingly, this does not happen if you just use the logging.warn/info/..()
function.
An example of a code that does not double the messages:
import tensorflow as tf
import logging
logging.warn('test')
An example of a code that does double all messages:
import tensorflow as tf
import logging
logger = logging.getLogger('TEST')
ch = logging.StreamHandler()
logger.addHandler(ch)
logger.warn('test')
Now, I'm a simple man. I like the functionality of logging
, so I use it. The setup with the logger
object and the adding of a StreamHandler
is something I picked up looking at how other people did this, but it looks like it fits with how the thing was meant to be used. However, I do not have in-depth knowledge of the logging library, as it always just kind of worked.
So, any help explaining why the doubling of the messages occurs will be most helpful.
I am using Ubuntu 14.04.3 LTS with Python 2.7.6, but the error happens in all Python 2.7 versions I tried.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…