Skip to content

Commit f736424

Browse files
committed
doc tweaks
1 parent 1284863 commit f736424

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

references/Developer Guide to Logging.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ When using the `ArduinoLog` library, the logging methods correspond to different
2727
- Corresponds to `Log.warning()`.
2828
- Example: `Log.warning("This is a warning");`
2929

30-
5. **`LOG_LEVEL_INFO` and `LOG_LEVEL_NOTICE` **:
30+
5. **`LOG_LEVEL_INFO` and `LOG_LEVEL_NOTICE`**:
3131

3232
- Informational messages, warnings, and errors.
3333
- Corresponds to `Log.info()` and `Log.notice()`.
@@ -61,23 +61,27 @@ To use logging in your code, include the following:
6161

6262
### Examples
6363

64+
##### (note: all of these methods have variants without the trailing 'ln' e.g. Log.info(). The difference being the ln variant adds a newline character (\n))
65+
6466
```cpp
65-
Log.info("This is an info message.");
66-
Log.warning("Warning: Device is overheating!");
67-
Log.error("Error: Sensor not found.");
68-
Log.fatal("Fatal: System crash imminent!");
69-
Log.info("Sensor value: " + String(sensorValue));
70-
71-
Log.info("Count: %d", count);
72-
Log.info("Status: %s, Value: %d", status, value);
73-
Log.warning("Temperature: %.2f°C", temperature);
74-
Log.error("Error %d: %s", errorCode, errorMessage);
75-
Log.trace("Loop iteration: %d", loopCount);
76-
77-
Log.info("Device: " + String(deviceName) + ", ID: %d", deviceId);
78-
Log.warning("Battery level: %d%%, Status: %s", batteryLevel, status);
67+
Log.infonl("This is an info message.");
68+
Log.warningnl("Warning: Device is overheating!");
69+
Log.errornl("Error: Sensor not found.");
70+
Log.fatalnl("Fatal: System crash imminent!");
71+
Log.infonl("Sensor value: " + String(sensorValue));
72+
73+
Log.infonl("Count: %d", count);
74+
Log.infonl("Status: %s, Value: %d", status.c_str(), value);
75+
Log.warningnl("Temperature: %.2f°C", temperature);
76+
Log.errornl("Error %d: %s", errorCode, errorMessage.c_str());
77+
Log.tracenl("Loop iteration: %d", loopCount);
78+
79+
Log.infonl("Device: " + String(deviceName) + ", ID: %d", deviceId);
80+
Log.warningnl("Battery level: %d%%, Status: %s", batteryLevel, status.c_str());
7981
```
8082

83+
Do NOT use Arduino Strings directly for %s, but to use .c_str(), like in Serial.printf()
84+
8185
## General Guidance
8286

8387
1. Opt for using `Log` instead of `Serial.print` where possible.

0 commit comments

Comments
 (0)