Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging in non-experiment layers #87

Open
siriuslee opened this issue Feb 17, 2015 · 1 comment
Open

Logging in non-experiment layers #87

siriuslee opened this issue Feb 17, 2015 · 1 comment
Labels

Comments

@siriuslee
Copy link
Contributor

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:

import logging
logger = logging.getLogger('pyoperant.interface.arduino')
logger.debug('Something bad happened with the arduino!')

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.

@neuromusic
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants