Skip to content

Commit be52105

Browse files
committed
+Update docs and assets
1 parent 0fea620 commit be52105

File tree

13 files changed

+148
-67
lines changed

13 files changed

+148
-67
lines changed

ARTICLE.md

Lines changed: 69 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,17 @@ When a crash happens, the error message is only half the story. The other half i
134134

135135
```dart
136136
void main() {
137-
// 1. Configure [df_log](https://pub.dev/packages/df_log) to keep the last 50 log events in memory.
137+
// Configure [df_log](https://pub.dev/packages/df_log) to keep the last 50
138+
// log events in memory.
138139
Log.maxStoredLogs = 50;
139140
140-
// 2. Set up a callback for crash reporting.
141+
// Set up a callback for crash reporting.
141142
Log.addCallback((logItem) {
142143
// We only care about logs that are tagged as errors.
143144
if (logItem.tags.contains(#error)) {
144145
// Get the history of recent events.
145146
final history = Log.items.map((item) => item.toMap()).toList();
146-
147+
147148
// Compile the payload to send to your crash reporter.
148149
final payload = {
149150
'exception': logItem.message,
@@ -156,7 +157,10 @@ void main() {
156157
}
157158
});
158159
159-
runApp(MyApp());
160+
// runApp(MyApp());
161+
162+
// Somewhere else in your code...
163+
updateUserProfile();
160164
}
161165
162166
// Somewhere else in your code...
@@ -169,46 +173,54 @@ void updateUserProfile() {
169173
// This single line now does two things:
170174
// 1. Prints the error to the console for you.
171175
// 2. Triggers the callback to send a crash report WITH breadcrumbs.
172-
Log.err('Failed to update profile: $e', {#error, #profile, #network});
176+
Log.err('Failed to update profile: $e', {#profile, #network});
173177
}
174178
}
175179
```
176180
The `LogItem.toMap()` or `LogItem.toJson()` function will output detailed information about the log, including a unique id, a timestamp and more:
177181

178182
```json
179183
{
180-
"icon": "🟣",
181-
"location": "example/updateUserProfile #32",
182-
"message": "Navigated to profile screen.",
183-
"timestamp": "2025-07-03T04:03:39.517345",
184-
"tags": [
185-
"ui",
186-
"profile",
187-
"info"
188-
],
189-
"id": "186abf74-6ace-40ec-89f5-90edce1fb48c",
190-
"column": 7,
191-
"line": 32,
192-
"package": null,
193-
"library": "example/example.dart",
194-
"uri": "file:///Users/robmllze/Projects/flutter/dev_cetera/df_packages/packages/df_log/example/example.dart"
195-
}
196-
{
197-
"icon": "🔴",
198-
"location": "example/updateUserProfile #39",
199-
"message": "Failed to update profile: Exception: Connection timed out",
200-
"timestamp": "2025-07-03T04:03:39.521080",
201-
"tags": [
202-
"error",
203-
"profile",
204-
"network"
205-
],
206-
"id": "b465efdd-1add-4f39-843c-ab98e55dc18b",
207-
"column": 9,
208-
"line": 39,
209-
"package": null,
210-
"library": "example/example.dart",
211-
"uri": "file:///Users/robmllze/Projects/flutter/dev_cetera/df_packages/packages/df_log/example/example.dart"
184+
"exception": "Failed to update profile: Exception: Connection timed out",
185+
"extra": {
186+
"breadcrumbs": [
187+
{
188+
"icon": "🟣",
189+
"location": "screenshot3/updateUserProfile #36",
190+
"message": "Navigated to profile screen.",
191+
"timestamp": "2025-07-03T18:24:08.514177",
192+
"tags": [
193+
"ui",
194+
"profile",
195+
"info"
196+
],
197+
"id": "7861c3f3-1dda-457f-acb8-252c205b0426",
198+
"column": 7,
199+
"line": 36,
200+
"package": null,
201+
"library": "example/screenshot3.dart",
202+
"uri": "file:///Users/robmllze/Projects/flutter/dev_cetera/df_packages/packages/df_log/example/screenshot3.dart"
203+
},
204+
{
205+
"icon": "🔴",
206+
"location": "screenshot3/updateUserProfile #44",
207+
"message": "Failed to update profile: Exception: Connection timed out",
208+
"timestamp": "2025-07-03T18:24:08.518744",
209+
"tags": [
210+
"error",
211+
"profile",
212+
"network",
213+
"err"
214+
],
215+
"id": "baa41fc7-2a55-44b7-b43c-ec8acd20f031",
216+
"column": 9,
217+
"line": 44,
218+
"package": null,
219+
"library": "example/screenshot3.dart",
220+
"uri": "file:///Users/robmllze/Projects/flutter/dev_cetera/df_packages/packages/df_log/example/screenshot3.dart"
221+
}
222+
]
223+
}
212224
}
213225
```
214226

@@ -252,35 +264,35 @@ Here is a quick reference to all the main features available.
252264

253265
### Main Logging Methods
254266

255-
Log.info(msg, [tags]): For general informational messages. (🟣)
256-
Log.ok(msg, [tags]): For success operations. (🟢)
257-
Log.err(msg, [tags]): For errors or exceptions. (🔴)
258-
Log.alert(msg, [tags]): For warnings that need attention. (🟠)
259-
Log.start(msg, [tags]): To mark the beginning of a process. (🔵)
260-
Log.stop(msg, [tags]): To mark the end of a process. (⚫)
261-
Log.trace(msg, [tags]): For fine-grained debugging information. (⚪️)
262-
Log.printGreen(message): Prints a message in a specific color without any other formatting. Many other colors are available (printRed, printYellow, printBlue, etc.).
267+
- `Log.info(msg, [tags])`: For general informational messages. (🟣)
268+
- `Log.ok(msg, [tags])`: For success operations. (🟢)
269+
- `Log.err(msg, [tags])`: For errors or exceptions. (🔴)
270+
- `Log.alert(msg, [tags])`: For warnings that need attention. (🟠)
271+
- `Log.start(msg, [tags])`: To mark the beginning of a process. (🔵)
272+
- `Log.stop(msg, [tags])`: To mark the end of a process. (⚫)
273+
- `Log.trace(msg, [tags])`: For fine-grained debugging information. (⚪️)
274+
- `Log.printGreen(message)`: Prints a message in a specific color without any other formatting. Many other colors are available (`printRed`, `printYellow`, `printBlue`, etc.).
263275

264276
### Configuration (Static Properties on Log)
265277

266-
Log.enableStyling = true: Enables/disables ANSI colors and icons. Set this to false if your terminal does not supprt ANSI colors.
267-
Log.showTimestamps = true: Shows a HH:mm:ss.SSS timestamp on each log.
268-
Log.showTags = true: Shows tags like #auth #ui on each log.
269-
Log.showIds = false: Shows a unique ID on each log.
270-
Log.enableReleaseAsserts = false: By default, logs only work in debug mode. Set to true to enable logging in release builds (use with caution).
278+
- `Log.enableStyling = true`: Enables/disables ANSI colors and icons. Set this to false if your terminal does not supprt ANSI colors.
279+
- `Log.showTimestamps = true`: Shows a HH:mm:ss.SSS timestamp on each log.
280+
- `Log.showTags = true`: Shows tags like #auth #ui on each log.
281+
- `Log.showIds = false`: Shows a unique ID on each log.
282+
- `Log.enableReleaseAsserts = false`: By default, logs only work in debug mode. Set to true to enable logging in release builds (use with caution).
271283

272284
### In-Memory Storage & Callbacks
273285

274-
Log.storeLogs = true: If true, keeps a history of logs in memory.
275-
Log.maxStoredLogs = 50: Sets the max number of LogItem objects to store.
276-
Log.items: A Queue<LogItem> containing the stored logs.
277-
Log.addCallback(callback): Registers a function void Function(LogItem item) that runs for every log.
278-
Log.removeCallback(callback): Removes a previously registered callback.
286+
- `Log.storeLogs = true`: If true, keeps a history of logs in memory.
287+
- `Log.maxStoredLogs = 50`: Sets the max number of LogItem objects to store.
288+
- `Log.items`: A `Queue<LogItem>` containing the stored logs.
289+
- `Log.addCallback(callback)`: Registers a function void `Function(LogItem item)` that runs for every log.
290+
- `Log.removeCallback(callback)`: Removes a previously registered callback.
279291

280292
### Advanced Output
281293

282-
Log.useDeveloperLog(): Switches output to dart:developer's log function for a richer experience in some IDEs.
283-
Log.useStandardPrint(): Reverts the output to the standard print function.
294+
- `Log.useDeveloperLog()`: Switches output to **dart:developer's** log function for a richer experience in some IDEs.
295+
- `Log.useStandardPrint()`: Reverts the output to the standard print function.
284296

285297
---
286298

_README_CONTENT.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
- **IDE Integration:** Optionally uses `dart:developer`'s `log` function for a richer experience in some IDEs.
1212
- **Extensible:** Add custom callbacks to integrate with other services (e.g., crash reporting).
1313

14+
## 📸 Screenshot
15+
16+
<img src="https://raw.githubusercontent.com/dev-cetera/df_log/main/doc/assets/example.png" alt="Visual Studio Code Terminal" width="600">
17+
1418
## 🚀 Getting Started
1519

1620
For an introduction, please refer to this article:
@@ -19,11 +23,6 @@ For an introduction, please refer to this article:
1923
- **DEV.TO** [Dart Logging: Your New Best Friend](https://dev.to/dev_cetera/dart-logging-your-new-best-friebd-ae1)
2024
- **GITHUB** [Dart Logging: Your New Best Friend](https://github.com/dev-cetera/df_log/blob/main/ARTICLE.md)
2125

22-
23-
## 📖 Usage
24-
25-
<img src="https://raw.githubusercontent.com/dev-cetera/df_log/main/doc/assets/screenshot2.png" alt="Visual Studio Code Terminal" width="600">
26-
2726
### 💡 1. Categorized Logs
2827

2928
The package comes with a few default log types that you can use creatively.

doc/assets/example.png

283 KB
Loading

doc/assets/screenshot1.png

8.91 KB
Loading

doc/assets/screenshot2.png

-128 KB
Binary file not shown.

doc/assets/screenshot3.png

41.7 KB
Loading

doc/assets/scressnshot2.png

203 KB
Loading

example/example.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ void main() {
1515
Log.printPurple('This is printed in PURPLE!');
1616
Log.printBlack('This is printed in BLACK!');
1717
Log.printWhite('This is printed in WHITE!');
18+
Log.printWhite(Log.items.map((e) => e.toJson()));
1819
}

example/screenshot1.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'package:df_log/df_log.dart';
2+
3+
void main() {
4+
Log.ok('User successfully authenticated.');
5+
}

example/screenshot2.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import 'package:df_log/df_log.dart';
2+
3+
void main() {
4+
Log.start('Application starting...');
5+
Log.info('Checking for user session...');
6+
Log.alert('Network connection is slow. Retrying in 5s.');
7+
Log.ok('User session found and validated.');
8+
Log.err('Failed to load user preferences!');
9+
Log.stop('Application shutting down.');
10+
Log.printRed('This is printed in RED!');
11+
Log.printGreen('This is printed in GREEN!');
12+
Log.printBlue('This is printed in BLUE!');
13+
Log.printYellow('This is printed in YELLOW!');
14+
Log.printCyan('This is printed in CYAN!');
15+
Log.printPurple('This is printed in PURPLE!');
16+
Log.printBlack('This is printed in BLACK!');
17+
Log.printWhite('This is printed in WHITE!');
18+
}

0 commit comments

Comments
 (0)