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

feat: Improve logging #989

Merged
merged 14 commits into from
Apr 2, 2024
Merged

feat: Improve logging #989

merged 14 commits into from
Apr 2, 2024

Conversation

Koenkk
Copy link
Owner

@Koenkk Koenkk commented Mar 21, 2024

Credits to @Nerivec

@Nerivec
Copy link
Collaborator

Nerivec commented Mar 22, 2024

For base classes, tried to follow as below:

  • Anything that has the potential to spam a bit => debug
  • Error/failure => error
  • Possible error or lack of expected response => warning
  • Unsupported/unhandled => warning
  • Unsupported/unhandled with "breaking" result => error
  • Anything that will alter or has altered the network in some way (few but meaningful occurrences) => info
  • Similar logging at higher level by zigbee2mqtt => debug
  • Rest => debug

Copy link
Sponsor Contributor

@deviantintegral deviantintegral left a comment

Choose a reason for hiding this comment

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

This is great. In particular, consistently injecting the logger will make it much easier to alter logging for specific messages (such as bumping one from debug to warn) to simplify output.

One comment and idea, but I haven't actually reviewed the rest of the code.

const device = Device.byIeeeAddr(payload.ieeeAddr);

if (!device) {
debug.log(`Network address is from unknown device '${payload.ieeeAddr}'`);
logger.debug(`Network address is from unknown device '${payload.ieeeAddr}'`, NS);
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Could we change this to logger.warn? I can't see how this would happen in a well-functioning system and network. Wouldn't it mean that somehow a device has the proper network keys, but isn't recognized?

I was thinking of doing this over at #992 but then saw this much more comprehensive PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If I'm not mistaken, colliding networks (configs) can trigger a boatload of these "device is unknown to Z2M, but we saw a message from it" events. That's a potential source of spam, and even though this particular event is unlikely to be triggered very often (for now, until associated ZDO request supported globally), in my opinion, it wouldn't make sense to have just this one as warning, and the other similar events as debug.

PS: If we really need a warning for device lookup, it would probably be better to put it directly in the lookup functions; it cleans up the code (several places check for unknown/deleted and log it), and allows to handle the includeDeleted behavior, in regards to logging, internally.

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.

None yet

3 participants