Open siriuslee opened 9 years ago
oh wow. I'm ashamed to admin that I had no idea that the logging module could be used like this.
a nice reference: http://eric.themoritzfamily.com/learning-python-logging.html
let me see if I get this correctly...
each module (hardware or behavior) would have e.g.
import logging
logger = logging.getLogger(__name__)
then we can move all of the logger handling and configuration out of the Experiment object and into whatever application is calling it (e.g. behave
), snagging the appropriate loggers which we want to monitor with
import logging
log = logging.getLogger()
log.getLogger('pyoperant.interface').set_level(logging.DEBUG)
log.getLogger('pyoperant.behavior').set_level(logging.INFO)
email_handler = handlers.SMTPHandler(**SMTP_CONFIG)
log.addHandler(email_handler)
Am I thinking about this correctly?
We need to implement some standardized form for logging in the non-experimental layers (e.g. the interface layer). For instance, polling happens at the level of the interface with a DIO card and thus the actual values returned by the DIO are never known at the experiment level. However, for some debugging purposes it would be useful for our lab to record the value at every read. We would propose adding a logger to each module (at least the interface and component modules) that takes the form of:
That way a handler can be attached by the panel or experiment to write out to a file in case of any low-level issues. Also, logging inheritance seems really useful, so a naming scheme like this should allow one to control the logging level of all interface modules simultaneously.