analogger 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
[](https://github.com/thimpat/analogger/actions/workflows/test.yml)
|
|
3
2
|
[](https://github.com/thimpat/analogger/blob/main/README.md)
|
|
4
|
-
[](https://github.com/thimpat/analogger/actions/workflows/versioning.yml)
|
|
5
3
|
[](https://www.npmjs.com/package/analogger)
|
|
6
4
|
<img alt="semantic-release" src="https://img.shields.io/badge/semantic--release-19.0.2-e10079?logo=semantic-release">
|
|
7
5
|
|
|
@@ -287,23 +285,29 @@ Display the browser native message box if run from it; otherwise, it displays th
|
|
|
287
285
|
### setOptions()
|
|
288
286
|
|
|
289
287
|
|
|
290
|
-
| **Options**
|
|
291
|
-
|
|
292
|
-
| silent
|
|
293
|
-
| hideLog
|
|
294
|
-
| hideError
|
|
295
|
-
| hideHookMessage
|
|
296
|
-
| hidePassingTests
|
|
297
|
-
| logToDom
|
|
298
|
-
| logToFile
|
|
299
|
-
| logToRemote
|
|
300
|
-
| logMaxSize
|
|
301
|
-
| compressArchives
|
|
302
|
-
| compressionLevel
|
|
303
|
-
| addArchiveTimestamp
|
|
304
|
-
| logMaxArchives
|
|
305
|
-
| requiredLogLevel
|
|
306
|
-
| enableDate
|
|
288
|
+
| **Options** | **default** | **Expect** | **Description** |
|
|
289
|
+
|-----------------------|-------------|-----------------------------------|------------------------------------------------------------------------------------|
|
|
290
|
+
| silent | false | boolean | _Hide logs from console (not errors)_ |
|
|
291
|
+
| hideLog | false | boolean | _Same as above (silent has precedence over hideLog)_ |
|
|
292
|
+
| hideError | false | boolean | _Hide errors from console_ |
|
|
293
|
+
| hideHookMessage | false | boolean | _Hide the automatic message shown when some native console methods are overridden_ |
|
|
294
|
+
| hidePassingTests | false | boolean | _Hide Live test results_ |
|
|
295
|
+
| logToDom | false | string (DOM Selector) | _display log in a DOM container_ |
|
|
296
|
+
| logToFile | false | string (File path) | _write log to a file if running from Node_ |
|
|
297
|
+
| logToRemote | undefined | string (URL) | _Send log to a remote (more info in the next version)_ |
|
|
298
|
+
| logMaxSize | 0 | number | _Set maximum size for the log file_ |
|
|
299
|
+
| compressArchives | false | boolean | _Whether to archive and compress the logs after deleting an archive_ |
|
|
300
|
+
| compressionLevel | 1 | number | _Archive compression level (0 to 9 with 0 = no compression)_ |
|
|
301
|
+
| addArchiveTimestamp | true | boolean | _Whether to add a timestamp to the generated rotated logs_ |
|
|
302
|
+
| logMaxArchives | 3 | number | _Maximum number of log files to use_ |
|
|
303
|
+
| requiredLogLevel | "LOG" | "LOG" / "INFO" / "WARN" / "ERROR" | _Define the log level from which the system can show a log entry_ |
|
|
304
|
+
| enableDate | false | boolean | _Show date + time (instead of time only)_ |
|
|
305
|
+
| logToLocalStorage | false | boolean | _Persist logs in browser localStorage_ |
|
|
306
|
+
| logToLocalStorageMax | 50 | number | _Max entries to keep in localStorage_ |
|
|
307
|
+
| compressArchives | false | boolean | _If true, rotates log files into a .tar.gz archive_ |
|
|
308
|
+
| compressionLevel | 1 | number | _Gzip compression level (0-9)_ |
|
|
309
|
+
| addArchiveTimestamp | true | boolean | _Appends a consistent timestamp to rotated files_ |
|
|
310
|
+
| forceLidOn | false | boolean | _Automatically generates a short hash LID if one isn't provided_ |
|
|
307
311
|
|
|
308
312
|
<br/>
|
|
309
313
|
|
|
@@ -1185,6 +1189,69 @@ anaLogger.addPlugin("doSomething", doSomething);
|
|
|
1185
1189
|
|
|
1186
1190
|
|
|
1187
1191
|
|
|
1192
|
+
```
|
|
1193
|
+
|
|
1194
|
+
---
|
|
1195
|
+
|
|
1196
|
+
[](https://github.com/thimpat/analogger/actions/workflows/test.yml)
|
|
1197
|
+
[](https://github.com/thimpat/analogger/blob/main/README.md)
|
|
1198
|
+
[](https://www.npmjs.com/package/analogger)
|
|
1199
|
+
|
|
1200
|
+
Analogger is a highly customizable logger for Node and Browser environments. It logs to terminals, browser DOM, files, and remote servers.
|
|
1201
|
+
|
|
1202
|
+
---
|
|
1203
|
+
|
|
1204
|
+
## 🚀 New Features (v1.24+)
|
|
1205
|
+
|
|
1206
|
+
### 💾 Local Storage Persistence (Browser)
|
|
1207
|
+
You can now persist logs in the browser's Local Storage. This is useful for debugging issues that occur across page refreshes.
|
|
1208
|
+
|
|
1209
|
+
```javascript
|
|
1210
|
+
// Enable local storage logging
|
|
1211
|
+
anaLogger.setOptions({
|
|
1212
|
+
logToLocalStorage: true,
|
|
1213
|
+
logToLocalStorageMax: 100 // Keep last 100 logs
|
|
1214
|
+
});
|
|
1215
|
+
|
|
1216
|
+
// Restore logs from previous session after page reload
|
|
1217
|
+
anaLogger.restoreLogs();
|
|
1218
|
+
```
|
|
1219
|
+
|
|
1220
|
+
🗄️ Advanced Log Rotation & Archiving (Node)
|
|
1221
|
+
Manage large log files with automatic rotation and .tar.gz compression.
|
|
1222
|
+
|
|
1223
|
+
```javascript
|
|
1224
|
+
anaLogger.setOptions({
|
|
1225
|
+
logToFile: "./app.log",
|
|
1226
|
+
logMaxSize: 5 * 1024 * 1024, // 5MB
|
|
1227
|
+
logMaxArchives: 5,
|
|
1228
|
+
compressArchives: true, // Archive rotated logs into .tar.gz
|
|
1229
|
+
compressionLevel: 6, // Gzip level (1-9)
|
|
1230
|
+
addArchiveTimestamp: true // Add ISO timestamps to filenames
|
|
1231
|
+
});
|
|
1232
|
+
```
|
|
1233
|
+
|
|
1234
|
+
### New Helper Methods
|
|
1235
|
+
|
|
1236
|
+
> restoreLogs()
|
|
1237
|
+
|
|
1238
|
+
(Browser only) Reads the history from localStorage and re-prints the logs to the current console. Perfect for diagnosing crashes that trigger a page reload.
|
|
1239
|
+
|
|
1240
|
+
> getLids()
|
|
1241
|
+
|
|
1242
|
+
Returns a deep clone of all loaded Lids, including statistics like callCount, callTimes, and human-readable dates.
|
|
1243
|
+
|
|
1244
|
+
> forceResolveLineCall(bool)
|
|
1245
|
+
|
|
1246
|
+
When enabled, AnaLogger captures the exact file and line number where the log was called and attaches it to the context.
|
|
1247
|
+
|
|
1248
|
+
### Manual LID strings
|
|
1249
|
+
|
|
1250
|
+
If you don't want to pass objects, you can use a shorthand string format:
|
|
1251
|
+
|
|
1252
|
+
```javascript
|
|
1253
|
+
// AnaLogger will parse this string as a context object
|
|
1254
|
+
anaLogger.log("lid: USR_LOGIN, color: purple", "User logged in");
|
|
1188
1255
|
```
|
|
1189
1256
|
|
|
1190
1257
|
---
|