Azure / azure-iot-sdk-node

A Node.js SDK for connecting devices to Microsoft Azure IoT services
https://docs.microsoft.com/en-us/azure/iot-hub/
Other
261 stars 227 forks source link

fix: update debug logging #1032

Closed BertKleewein closed 3 years ago

BertKleewein commented 3 years ago

These changes are inspired by my current ICM. I think they would be useful to apply across the board. I'm fixing a few things:

  1. For processes with multiple device clients, there's no way to correlate which azure-iot* level operations correspond to which rhea operations. Adding the .toString() text to sender_link.ts and receiver_link.ts adds a [connection-n] prefix to our logs so it's easier to filter on a specific connection.
  2. There are no consistent "what did the customer call and did it succeed" logs. azure-iot-common:RetryOperation output is part-way there, but it needs more detail. I added lines here so we can see when an operation starts, when it finishes, if it fails, etc..
  3. There is no concept of "debug levels", so we can't set DEBUG values to show only errors, for instance.

Since my current runs produce 10-100 GB of log per run, I want to filter output as much as possible. With this code, I can run this with:

export DEBUG="rhea:frames*,azure-iot-common:RetryOperation*,azure*:Errors"

This way I get:

  1. Rhea traffic (rhea:frames*)
  2. What is causing that traffic. (azure-iot-common:RetryOperation*)
  3. What error code gets called as a result of this traffic. (azure*:Errors")
vishnureddy17 commented 3 years ago

I'm a fan of this. Since the debug library doesn't provide log levels, having something like this :Errors patten would be useful more broadly across our libraries. I also like the changes you made to be able to filter on a specific connection. Could we apply this to our other transports too?

Also, there's a logfile in this PR that doesn't seem like it is meant to be there.

-- the logfile is probably meant as an example to show how the log output looks.

YoDaMa commented 3 years ago

I agree with what @vishnureddy17 previously said. The addition of some Errors debugging level would be useful. I also have no issue with finer grained specificity for each link on our RHEA logs. Overall these will make our life easier with debugging.