`basicConfig()` could affect root logger
Hi,
While investigating unexpected extra logs in a project, I noticed this repo is a dependency and configures logging with logging.basicConfig():
https://github.com/Dragon2fly/ZipUnicode/blob/412b9422469069fe580c219ef683639a4192e088/zip_unicode/main.py#L20-L21
This config applies to the root logger, and it can unintentionally affect other libraries. In my case, logs from httpx started appearing at INFO, which should normally suppressed at WARNING level:
HTTP Request: POST http://localhost:7860/api/predict "HTTP/1.1 200 OK"
HTTP Request: POST http://localhost:7860/api/predict "HTTP/1.1 200 OK"
HTTP Request: POST http://localhost:7860/reset "HTTP/1.1 200 OK"
HTTP Request: POST http://localhost:7860/reset "HTTP/1.1 200 OK"
Related code from httpx package:
https://github.com/encode/httpx/blob/3fee27838e9fd0cb528861e41f3ff98164081a4b/httpx/_client.py#L1025-L1032
Would you consider configuring only the package’s own logger logging.getLogger("zip_unicode") instead of the root logger? That way, it won’t interfere with other code.
Thanks!
Hi @lazydogP
Can you provide more details about your use case? How did you use ZipUnicode?
Anyhow, ZipUnicode was intended to be used as a standalone executor. That is why it configures the logger independently.
Could you let me know your use case so I can change the log config accordingly?
Hi @lazydogP
Can you provide more details about your use case? How did you use ZipUnicode?
I'm using this extension for Stable Diffusion WebUI: https://github.com/BlafKing/sd-civitai-browser-plus
It uses ZipUnicode to handle zip files with Unicode filenames in it as described here: https://github.com/BlafKing/sd-civitai-browser-plus/discussions/43
Done in v1.2.0.
logging.basicConfig() will only be called in the standalone zipu command.
Using it as a library will not configure the logging.