Skip to content

chore: Change logger name to 'PyViCare...'#738

Merged
CFenner merged 1 commit intoopenviess:masterfrom
lackas:fix/logger-name
Apr 11, 2026
Merged

chore: Change logger name to 'PyViCare...'#738
CFenner merged 1 commit intoopenviess:masterfrom
lackas:fix/logger-name

Conversation

@lackas
Copy link
Copy Markdown
Contributor

@lackas lackas commented Apr 11, 2026

All 7 modules use logging.getLogger('ViCare'), but Home Assistant's vicare integration registers "loggers": ["PyViCare"] in its manifest.json. This mismatch means HA's logger configuration for the integration has no effect on the library's log output.

Renaming to 'PyViCare' matches the package name (Python convention) and makes HA's logger settings work as expected.

@lackas
Copy link
Copy Markdown
Contributor Author

lackas commented Apr 11, 2026

@CFenner Quick question: the library uses logging.getLogger('ViCare') but HA's manifest registers "loggers": ["PyViCare"]. Was the ViCare name intentional (to separate library logs from integration logs), or is the mismatch unintended?

If ViCare is intentional, the fix should be on the HA side instead (manifest.json"loggers": ["ViCare"]). Happy to adjust either way.

@lackas
Copy link
Copy Markdown
Contributor Author

lackas commented Apr 11, 2026

Alternatively, I could switch to logging.getLogger(__name__) instead of a hardcoded string — that would give per-module loggers (PyViCare.PyViCareCachedService, etc.) which makes it easier to trace where a log line came from. Downside is it changes the log output format. Happy to go either way.

@CFenner
Copy link
Copy Markdown
Member

CFenner commented Apr 11, 2026

I think it is intentional as it matches the integration name.

Actually I have no idea what the manifest entry is for.

@lackas
Copy link
Copy Markdown
Contributor Author

lackas commented Apr 11, 2026

The loggers field in manifest.json tells HA which library loggers to enable when a user turns on debug logging for the integration via the UI. Right now the manifest has "loggers": ["PyViCare"], but the library uses getLogger('ViCare') — so enabling debug for the integration gives you integration-level logs but nothing from the library.

I confirmed this on our system: with debug enabled, zero [ViCare] lines in the output.

We could fix it on the HA side (change manifest to "loggers": ["ViCare"]), but I think using the package name PyViCare as the logger namespace is more predictable — it's what you'd expect when looking at the installed package. Happy to go either way though.

@CFenner
Copy link
Copy Markdown
Member

CFenner commented Apr 11, 2026

Ah, Sorry thought this is the HA repo 🙄 would be nice if you could switch to the more meaningful name.

All modules used logging.getLogger('ViCare') which doesn't match the
package name and prevents HA's manifest loggers field from capturing
library debug output. Switch to __name__ for standard Python per-module
logging (e.g. PyViCare.PyViCareService, PyViCare.PyViCareCachedService).
@lackas
Copy link
Copy Markdown
Contributor Author

lackas commented Apr 11, 2026

Updated to use __name__ instead of hardcoded 'PyViCare' — gives per-module granularity (e.g. PyViCare.PyViCareService, PyViCare.PyViCareCachedService) while still being captured by HA's "loggers": ["PyViCare"] manifest entry thanks to Python's hierarchical logging.

@CFenner CFenner changed the title Fix logger name: 'ViCare' -> 'PyViCare' chore: Change logger name to 'PyViCare...' Apr 11, 2026
@CFenner CFenner merged commit c416bd4 into openviess:master Apr 11, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants