8000 Use voluptuous for logger by fabaff · Pull Request #3375 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use voluptuous for logger #3375

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

Merged
merged 2 commits into from
Sep 18, 2016
Merged

Use voluptuous for logger #3375

merged 2 commits into from
Sep 18, 2016

Conversation

fabaff
Copy link
Member
@fabaff fabaff commented Sep 13, 2016

Description:
Migration of the configuration check to voluptuous.

Related issue (if applicable): fixes 127528299

Example entry for configuration.yaml (if applicable):

logger:
  default: critical
  logs:
    homeassistant.components: info
    homeassistant.components.mqtt: debug
    homeassistant.components.biary_sensor: critical

It would be nice if somebody could take a look at the changes and run a quick test. Thanks.

@fabaff fabaff mentioned this pull request Sep 13, 2016
cv.ensure_list,
[
vol.Schema({
cv.string: vol.In(vol.Lower(list(LOGSEVERITY))),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about making this cv.slug: iso cv.string:? It forces lowercase and allowable characters

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cv.string is correct. From the logger.getLogger(…) docs:

Return a logger with the specified name or, if name is None, return a logger which is the root logger of the hierarchy. If specified, the name is typically a dot-separated hierarchical name like ‘a’, ‘a.b’ or ‘a.b.c.d’. Choice of these names is entirely up to the developer who is using logging.

@kellerza
Copy link
Member

One comment, but otherwise it looks good! 🐬

@@ -23,6 +27,22 @@
LOGGER_DEFAULT = 'default'
LOGGER_LOGS = 'logs'

_LOGS_SCHEMA = vol.All(
cv.ensure_list,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be a list, just the vol.Schema({…}) part is needed.

From the code line 84:

for key, value in config.get(DOMAIN)[LOGGER_LOGS].items():
    …

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that my brain went into a "there is a list" loop for the last vol PRs.

@balloob balloob merged commit 2b7d1fe into home-assistant:dev Sep 18, 2016
@tylerstraub
Copy link

@fabaff

I am getting error output for my logger service now after this last rebase:

16-09-19 16:42:51 homeassistant.bootstrap: Invalid config for [logger]: required key not provided @ data['logger']['logs']. Got None

Seems I can no longer define a default log level.

@balloob balloob mentioned this pull request Sep 20, 2016
2 tasks
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
@fabaff fabaff deleted the voluptuous-logger branch April 12, 2017 07:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0