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

mention the hierarchical namespace for logging #2786

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

ghoz
Copy link
Contributor

@ghoz ghoz commented Jun 3, 2024

Documents hierarchical namespace log levels
Koenkk/zigbee2mqtt#22859

```

## Defining levels for specific namespace hierarchy
The log levels defined in `log_namespaced_levels` will apply to the namespace itself and all namespaces below unless explicitely configured.
In addition to the regex based debug filter [#preventing-specific-namespaces-from-being-logged] it allows to fine tune your logging needs to great detail.
Copy link
Contributor

Choose a reason for hiding this comment

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

The log levels defined in log_namespaced_levels will apply to the namespace itself and all namespaces below unless explicitely configured.
In addition to the regex based debug filter [#preventing-specific-namespaces-from-being-logged] it allows to fine tune your logging needs to great detail.

=>
Any log level defined in log_namespaced_levels will apply to the namespace itself and all namespaces below it, unless explicitly configured.


Regex part is described below and only applies to debug, so I don't think we need to mention it here.

log_level: warning
log_namespaced_levels:
'zhc': info
'zhc:legacy:fz' : debug
Copy link
Contributor

Choose a reason for hiding this comment

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

advanced:
  log_level: warning
  log_namespaced_levels:
    zhc: info
    zhc:legacy:fz: debug

(same at the top, can remove the quotes wrapping namespace)


- All namespaces bellow `zhc` will be logged as info
- Except all namespaces bellow `zhc:legacy:fz` that will be logged as debug
- All the rest uses the `warning` level`
Copy link
Contributor

Choose a reason for hiding this comment

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

- All namespaces bellow `zhc` will be logged as info
- Except all namespaces bellow `zhc:legacy:fz` that will be logged as debug
- All the rest uses the `warning` level`

=>

- `zhc` and below namespaces will be logged as `info` (examples: `zhc`, `zhc:ota:common`, `zhc:legacy:tz`)
- `zhc:legacy:fz` and below namespaces will be logged as `debug` (examples: `zhc:legacy:fz`, `zhc:legacy:fz:tuya`)
- Other unspecified namespaces will use `log_level`, in this case, `warning` (examples: `z2m:mqtt`, `zh:zstack`)

@Koenkk Koenkk merged commit 5fbfa80 into Koenkk:develop Jun 4, 2024
1 check passed
@Koenkk
Copy link
Owner

Koenkk commented Jun 4, 2024

Thanks!

@ghoz ghoz deleted the log-namespace-hierarchy branch June 4, 2024 21:03
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

Successfully merging this pull request may close these issues.

3 participants