Aharoni-Lab / miniscope-io

Data formatting, reading, and writing from miniscopes
https://miniscope-io.readthedocs.io
GNU Affero General Public License v3.0
6 stars 2 forks source link

Single root logger handler :) #73

Open sneakers-the-rat opened 1 week ago

sneakers-the-rat commented 1 week ago

Fix: https://github.com/Aharoni-Lab/miniscope-io/issues/69

Instead of having each logger having their own handler, we instead have one single root logger miniscope_io that has all the handlers, and then all the child loggers propagate messages up to it.

The biggest change in behavior here is that we now will have a single log file (or, rather, n log files depending on how many rotating files we have configured) rather than a log file per logger. If we prefer that, we can go back to that, but it requires us to also have multiple stdout handlers since we need to set propagate = false at the logger level to prevent double-logging, which we have mostly avoided by chance from not having any nested loggers.

Opening this as a draft for the moment because I think this will play screwy with multiprocessing, so let me test that real quick too.

edit: ok added multiprocessing handling - if a logger is spawned in a child process, it logs to a separate file that includes the logger's name as well as the PID (anticipating people wanting to run multiple of the same kind of miniscope on the same machine).


📚 Documentation preview 📚: https://miniscope-io--73.org.readthedocs.build/en/73/

coveralls commented 1 week ago

Coverage Status

coverage: 77.514% (+0.3%) from 77.22% when pulling d5496ba024178d2a91c47fb1c3753c3cd14c3bc9 on bugfix_loglevel_config into 87487a1db75d2b59fabfe96dc60653079b0c5f21 on main.