Skip to content

Commit

Permalink
Logging: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Aug 7, 2024
1 parent fd049ec commit 0d18029
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,22 @@ public void setTarget(@NonNull final BluetoothDevice device) {
// more readable in the nRF Logger app.
@SuppressLint("WrongConstant")
@Override
protected void log(int priority, final String tag, final String message, final Throwable t) {
protected void log(int priority, final String tag, final @NonNull String message, final Throwable t) {
if (getSession() == null)
return;

int level = priority;
// Print messages starting with Sending and Received as APPLICATION level.
// Those contain parsed CBOR values and are printed in McuMgrBleTransport.
if (message.startsWith("Sending") || message.startsWith("Received")) {
if (message.startsWith("Sending") || message.startsWith("Received") || message.startsWith("Upload completed")) {
level = LogContract.Log.Level.APPLICATION;
}
// RC is returned in case of an error. "err" is returned in Version 2 of SMP protocol.
if (message.contains("\"rc\":") || message.contains("\"err\":")) {
level = Log.WARN;
}
super.log(level, tag, message, t);
// Skip the tag, Proguard obfuscates it anyway.
super.log(level, null, message, t);
}

};
Expand Down

0 comments on commit 0d18029

Please sign in to comment.