-
Notifications
You must be signed in to change notification settings - Fork 13
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
Setting logging.basicConfig
causes exception on save()
#37
Comments
logging.basicConfig
causes Exception on save()logging.basicConfig
causes exception on save()
As a workaround, it is possible to avoid invoking import logging
from snirf import Snirf
fmt = logging.Formatter(
fmt="%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s",
datefmt="%Y-%m-%d:%H:%M:%S",
)
_filelogger = logging.FileHandler("test.log")
_filelogger.setLevel(logging.DEBUG)
_filelogger.setFormatter(fmt)
_streamlogger = logging.StreamHandler()
_streamlogger.setLevel(logging.WARNING)
_streamlogger.setFormatter(fmt)
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
log.addHandler(_filelogger)
log.addHandler(_streamlogger)
with Snirf("test.snirf", "w") as f:
f.nirs.appendGroup()
f.save()
log.debug("debug")
log.warning("warning") Nevertheless, I think it's still better to fix the cause of the exception. |
Hi, thanks for this--sorry to see I have misused the logging module. I am not actively maintaining this project and will take awhile to get to this fix. I can help you integrate the changes with the generative code if you make the necessary changes to the header.py |
Thanks for the response. I'd love to contribute, but right now I'm too busy elsewhere, sorry. With the above workaround, my code works fine, and perhaps others who bump into the same issue can learn from it too. I hope you find the time to work on it one day. |
It seems to be fixed in: Is there a chance to trigger new official release? |
I will try and move through a release now/in the coming days @ptrhbt |
Hopefully this is fixed in the new release but I will await confirmation |
Hi,
Windows 11
Python 3.11.4
snirf 0.7.4
I'm learning to use the module to create snirf files from scratch. I've run into a problem, where my code also uses the
logging
module and setslogging.basicConfig
, and it results in aTypeError
exception being thrown onsave()
. Minimal example follows:Running this code results in:
No exception is thrown if the code only changes a property of the snirf root (e.g.
formatVersion
), but doesn't append anirs
group. Removing thelogging.basicConfig
line also removes the error.The text was updated successfully, but these errors were encountered: