analogger 2.3.2 → 2.3.3
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 +31 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -379,6 +379,37 @@ _The data received by your server may look like this:_
|
|
|
379
379
|
> Your server must support the POST method.
|
|
380
380
|
|
|
381
381
|
|
|
382
|
+
<br/>
|
|
383
|
+
|
|
384
|
+
##### Backend implementation example
|
|
385
|
+
|
|
386
|
+
To receive remote logs from the frontend, you can implement a simple endpoint in your Node.js/Express-like backend:
|
|
387
|
+
|
|
388
|
+
```javascript
|
|
389
|
+
// Endpoint to receive remote logs from the frontend
|
|
390
|
+
router.post("/api/logs", (req, res) => {
|
|
391
|
+
try {
|
|
392
|
+
const logs = req.body;
|
|
393
|
+
if (Array.isArray(logs)) {
|
|
394
|
+
if (logs.length > 0) {
|
|
395
|
+
for (const log of logs) {
|
|
396
|
+
const context = log[0] || {};
|
|
397
|
+
const message = log[1];
|
|
398
|
+
anaLogger.log({
|
|
399
|
+
lid: "REMOTE00",
|
|
400
|
+
symbol: "airplane"
|
|
401
|
+
}, `[${context.lid}][${context.contextName}] ${message}`);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
res.json({ success: true });
|
|
406
|
+
} catch (error) {
|
|
407
|
+
anaLogger.error({ lid: "API10017" }, "Error processing remote logs:", error);
|
|
408
|
+
res.status(status.INTERNAL_SERVER_ERROR).json({ success: false, error: status[status.INTERNAL_SERVER_ERROR] });
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
```
|
|
412
|
+
|
|
382
413
|
<br/>
|
|
383
414
|
<br/>
|
|
384
415
|
|