You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ARTICLE.md
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -275,7 +275,8 @@ Here is a quick reference to all the main features available.
275
275
276
276
### Configuration (Static Properties on Log)
277
277
278
-
-`Log.enableStyling = true`: Enables/disables ANSI colors and icons. Set this to false if your terminal does not supprt ANSI colors.
278
+
-`Log.context = 'MAIN'`: Labels the current isolate. Shows inside the log brackets so you can tell which isolate printed what.
279
+
-`Log.enableStyling = true`: Enables/disables ANSI colors and icons. Set this to false if your terminal does not support ANSI colors.
279
280
-`Log.showTimestamps = true`: Shows a HH:mm:ss.SSS timestamp on each log.
280
281
-`Log.showTags = true`: Shows tags like #auth #ui on each log.
281
282
-`Log.showIds = false`: Shows a unique ID on each log.
@@ -286,8 +287,32 @@ Here is a quick reference to all the main features available.
286
287
-`Log.storeLogs = true`: If true, keeps a history of logs in memory.
287
288
-`Log.maxStoredLogs = 50`: Sets the max number of LogItem objects to store.
288
289
-`Log.items`: A `Queue<LogItem>` containing the stored logs.
290
+
-`Log.clear()`: Clears all stored logs.
289
291
-`Log.addCallback(callback)`: Registers a function void `Function(LogItem item)` that runs for every log.
290
292
-`Log.removeCallback(callback)`: Removes a previously registered callback.
293
+
-`Log.onLogDiscarded`: Called when old logs are removed from the queue (when full).
294
+
-`Log.exportLogsAsJsonLines()`: Exports all stored logs as a JSONL string.
295
+
296
+
### Multi-Isolate Debugging
297
+
298
+
In Dart, each isolate has its own memory. All `Log` statics (`context`, `items`, `activeTags`, etc.) are independent per isolate. Set `Log.context` at the start of each isolate to label it:
-**Release Mode Control:** Configure logs and assertions to be active even in release builds.
25
25
-**Customizable Output:** Show or hide timestamps, log IDs, and tags.
26
26
-**IDE Integration:** Optionally uses `dart:developer`'s `log` function for a richer experience in some IDEs.
27
+
-**Isolate-Friendly:** Set `Log.context` per isolate to instantly see where logs come from. Works on web too.
28
+
-**Log Export:** Export stored logs as JSONL with `Log.exportLogsAsJsonLines()`.
27
29
-**Extensible:** Add custom callbacks to integrate with other services (e.g., crash reporting).
28
30
29
31
## 📸 Screenshot
@@ -100,12 +102,40 @@ void main() {
100
102
}
101
103
```
102
104
103
-
### 💡 3. Configuration
105
+
### 💡 4. Isolate Context
106
+
107
+
When debugging across isolates, set `Log.context` at the start of each isolate. Since Dart statics are per-isolate, each isolate gets its own value automatically - no locking, no shared state, no complexity.
108
+
109
+
```dart
110
+
void main() {
111
+
Log.context = 'MAIN';
112
+
Log.info('Starting app');
113
+
// Output: [🟣 example #5 MAIN] Starting app
114
+
runApp(const App());
115
+
}
116
+
117
+
@pragma("vm:entry-point")
118
+
void overlayMain() {
119
+
Log.context = 'OVERLAY';
120
+
Log.info('Overlay started');
121
+
// Output: [🟣 example #5 OVERLAY] Overlay started
122
+
runApp(const Overlay());
123
+
}
124
+
```
125
+
126
+
Use a short tag like `M` to save space, or a full string like `ISOLATE_MAIN` for clarity.
127
+
128
+
**How it works:** In Dart, each isolate has its own memory. All `Log` statics (`context`, `items`, `activeTags`, etc.) are independent per isolate. This means `Log.context = 'OVERLAY'` in one isolate has zero effect on another. The only shared thing is the console output (stdout), which is why `Log.context` exists - so you can tell which isolate printed what. This works on all platforms including web.
129
+
130
+
### 💡 5. Configuration
104
131
105
132
You can customize the logging behavior to suit your needs, including styling, output format, and storage options. The Log class provides various settings to control how logs are displayed and managed.
106
133
107
134
```dart
108
135
void main() {
136
+
// Set a label for the current isolate (useful for multi-isolate debugging).
137
+
Log.context = 'MAIN';
138
+
109
139
// Enable or disable ANSI colors and icons. Disable this if your console doesn't support it.
110
140
Log.enableStyling = true;
111
141
@@ -142,6 +172,17 @@ void main() {
142
172
// Remove an existing callback.
143
173
Log.removeCallback(callback);
144
174
175
+
// Get notified when old logs are discarded from the queue.
Copy file name to clipboardExpand all lines: _README_CONTENT.md
+42-1Lines changed: 42 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@
9
9
-**Release Mode Control:** Configure logs and assertions to be active even in release builds.
10
10
-**Customizable Output:** Show or hide timestamps, log IDs, and tags.
11
11
-**IDE Integration:** Optionally uses `dart:developer`'s `log` function for a richer experience in some IDEs.
12
+
-**Isolate-Friendly:** Set `Log.context` per isolate to instantly see where logs come from. Works on web too.
13
+
-**Log Export:** Export stored logs as JSONL with `Log.exportLogsAsJsonLines()`.
12
14
-**Extensible:** Add custom callbacks to integrate with other services (e.g., crash reporting).
13
15
14
16
## 📸 Screenshot
@@ -85,12 +87,40 @@ void main() {
85
87
}
86
88
```
87
89
88
-
### 💡 3. Configuration
90
+
### 💡 4. Isolate Context
91
+
92
+
When debugging across isolates, set `Log.context` at the start of each isolate. Since Dart statics are per-isolate, each isolate gets its own value automatically - no locking, no shared state, no complexity.
93
+
94
+
```dart
95
+
void main() {
96
+
Log.context = 'MAIN';
97
+
Log.info('Starting app');
98
+
// Output: [🟣 example #5 MAIN] Starting app
99
+
runApp(const App());
100
+
}
101
+
102
+
@pragma("vm:entry-point")
103
+
void overlayMain() {
104
+
Log.context = 'OVERLAY';
105
+
Log.info('Overlay started');
106
+
// Output: [🟣 example #5 OVERLAY] Overlay started
107
+
runApp(const Overlay());
108
+
}
109
+
```
110
+
111
+
Use a short tag like `M` to save space, or a full string like `ISOLATE_MAIN` for clarity.
112
+
113
+
**How it works:** In Dart, each isolate has its own memory. All `Log` statics (`context`, `items`, `activeTags`, etc.) are independent per isolate. This means `Log.context = 'OVERLAY'` in one isolate has zero effect on another. The only shared thing is the console output (stdout), which is why `Log.context` exists - so you can tell which isolate printed what. This works on all platforms including web.
114
+
115
+
### 💡 5. Configuration
89
116
90
117
You can customize the logging behavior to suit your needs, including styling, output format, and storage options. The Log class provides various settings to control how logs are displayed and managed.
91
118
92
119
```dart
93
120
void main() {
121
+
// Set a label for the current isolate (useful for multi-isolate debugging).
122
+
Log.context = 'MAIN';
123
+
94
124
// Enable or disable ANSI colors and icons. Disable this if your console doesn't support it.
95
125
Log.enableStyling = true;
96
126
@@ -127,6 +157,17 @@ void main() {
127
157
// Remove an existing callback.
128
158
Log.removeCallback(callback);
129
159
160
+
// Get notified when old logs are discarded from the queue.
0 commit comments