@lark-apaas/devtool-kits 0.1.0-alpha.7 → 0.1.0-alpha.8
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 +383 -185
- package/dist/index.cjs +26 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29214,6 +29214,31 @@ function collectLogsHandler(logDir, fileName) {
|
|
|
29214
29214
|
};
|
|
29215
29215
|
}
|
|
29216
29216
|
__name(collectLogsHandler, "collectLogsHandler");
|
|
29217
|
+
function collectLogsBatchHandler(logDir, fileName) {
|
|
29218
|
+
const filePath = join4(logDir, fileName);
|
|
29219
|
+
ensureDir(logDir);
|
|
29220
|
+
return async (req, res) => {
|
|
29221
|
+
try {
|
|
29222
|
+
const logContents = req.body;
|
|
29223
|
+
if (!Array.isArray(logContents)) {
|
|
29224
|
+
return res.status(400).json({
|
|
29225
|
+
message: "logContents must be an array"
|
|
29226
|
+
});
|
|
29227
|
+
}
|
|
29228
|
+
const logLines = [];
|
|
29229
|
+
for (const logContent of logContents) {
|
|
29230
|
+
logLines.push(JSON.stringify(logContent) + "\n");
|
|
29231
|
+
}
|
|
29232
|
+
await fs8.promises.appendFile(filePath, logLines.join(""));
|
|
29233
|
+
res.json({
|
|
29234
|
+
success: true
|
|
29235
|
+
});
|
|
29236
|
+
} catch (error) {
|
|
29237
|
+
handleError2(res, error, "Failed to collect logs");
|
|
29238
|
+
}
|
|
29239
|
+
};
|
|
29240
|
+
}
|
|
29241
|
+
__name(collectLogsBatchHandler, "collectLogsBatchHandler");
|
|
29217
29242
|
function handleError2(res, error, message = "Failed to collect logs") {
|
|
29218
29243
|
res.status(500).json({
|
|
29219
29244
|
message,
|
|
@@ -29227,6 +29252,7 @@ function createDevLogRouter2(options = {}) {
|
|
|
29227
29252
|
const logDir = resolveLogDir2(options.logDir);
|
|
29228
29253
|
const router = import_express3.default.Router();
|
|
29229
29254
|
router.post("/collect", import_express3.default.json(), collectLogsHandler(logDir, options.fileName || "client.log"));
|
|
29255
|
+
router.post("/collect-batch", import_express3.default.json(), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
|
|
29230
29256
|
return router;
|
|
29231
29257
|
}
|
|
29232
29258
|
__name(createDevLogRouter2, "createDevLogRouter");
|