eclipse-hono / hono

Eclipse Hono™ Project
https://eclipse.dev/hono
Eclipse Public License 2.0
450 stars 137 forks source link

Add optional message tracing logs for CoAP adapter #3656

Open harism opened 4 hours ago

harism commented 4 hours ago

Shortly the idea is, which I'm willing to implement if agreed so;

  1. Add a configuration flag to enable CoAP message tracing logs in CoAP adapter - false by default
  2. Add Californium default MessageTracer interceptor in the code to use based on the flag setting

Enabling this flag will add INFO level logs from default MessageTracer which look similar to this example;

UDP(10.244.3.155:55816) ==> req CON-PUT    MID=43112, Token=C813, OptionSet={"Uri-Path":["t","test"]}, FC 00 <-- payload

Purpose is to see message details especially in situations where they do not map into uri-paths which Hono implements and in these rare cases can be difficult to understand why the message doesn't even reach to Hono and Californium discards it already.

Usually that would mean that the client does not follow CoAP specification closely enough, and this flag is kind of a debug mode where every message gets logged with details it carries.

However there is always the security aspect to consider too with this kind of features.

sophokles73 commented 3 hours ago

Sounds reasonable. The only caveat I see is that we should not include the payload in the logs ...

harism commented 1 hour ago

Do you mean that payload should not be logged at all or are you worried about the length instead?

In case of the length this default MessageTracer use seems to limit payload output to max 32 characters long.