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

Do NOT create logging.conf #162

Open
rgerganov opened this issue Jul 23, 2020 · 4 comments
Open

Do NOT create logging.conf #162

rgerganov opened this issue Jul 23, 2020 · 4 comments

Comments

@rgerganov
Copy link

There is this in coap.py:

if not os.path.isfile("logging.conf"):
    create_logging()

Libraries are NOT supposed to create configuration files. If there is no configuration file, you certainly shouldn't create one.

@8749236
Copy link

8749236 commented Aug 2, 2020

I agree, sometimes logging.conf will conflict with existing code base logging config.
It causes log to get duplicated since stream handler is added twice to root handler. Since coapthon is a library, the only acceptable way to fix it is disabling project's logging config.

What's more, whenever I run program that uses coapthon from different directory, it creates logging.conf all over the place.
It is also a headache when I want two programs, both uses coapthon, to have different logging config.

@jackjansen
Copy link

I fully agree: it is very bad form for a library to mess with the global logging structure. If you want to do logging in a specific manner for your library you should setup sub-loggers and apply any configuration changes there.

I have spent 4 weeks (not fulltime, but still) debugging why some of my programs were suddenly giving all sorts of spurious log messages from all sort of modules. Turned out that it was because My program was using a package which was using another package which had started importing coap. I was not using the soap functionality at all.

The only way I finally managed to find that CoAPthon was the culprit was when I had the brainwave to put a syntax error in the logging.conf generator:-)

@jackjansen
Copy link

@Tanganelli is there any chance of progress on this issue? I'm using CoAPthon in a tool I distribute (not widely, but still:-), and all users of that tool end up with

  1. All Python loggers including for completely different packages going into verbose debug logging,
  2. logging.conf files left all over their filesystem (wherever the even once ran my tool).

I really dislike forking PyPi packages, because it's going to be an endless source of confusion to users of a package (besides it seems like I'd be taking credit for your work), but unless you can fix this in the foreseeable future I don't see another option...

@8749236
Copy link

8749236 commented Jan 8, 2021

@jackjansen Alternative solution is to write code to delete "logging.conf" whenever program exits.
But I personally prefer modifying coapthon source since there are some bugs within the package that I need to fix anyway.

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

No branches or pull requests

3 participants