mjhoptics / ray-optics

geometric ray tracing for optical systems
BSD 3-Clause "New" or "Revised" License
263 stars 54 forks source link

Prefer using local loggers #138

Closed dominikonysz closed 4 months ago

dominikonysz commented 7 months ago

Hey Michael,

would it be possible to replace the global logging (e.g. logging.info) with local loggers?

logger = logging.getLogger(__name__)
logger.info(...)

I'm having the issue that when using an INFO log level some logs from rayoptics are also printed. Since they are using the root logger I cannot just hide the logs coming from rayoptics. Particularly the one at medium.py:109 is printed very often in my case.

I was thinking of providing you with a PR but realized that there are some cases where you are logging into files. It didn't seem so straightforward to refactor them in a simple way while adhering to your style. Neither it would have been a good approach to just refactor the ones bothering me.

It's not a very urgent thing for me but maybe you could keep that in mind whenever you do something to the code next time.

mjhoptics commented 7 months ago

Hello @dominikonysz,

I must confess that my implementation of logging was done before I knew what I was doing with either logging or python. I don't use what is currently generated so if you want to propose changes, I'm open to suggestions that would make logging more useful and/or less annoying.

Regards,

Mike Hayford