@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.cjs
CHANGED
|
@@ -29226,6 +29226,31 @@ function collectLogsHandler(logDir, fileName) {
|
|
|
29226
29226
|
};
|
|
29227
29227
|
}
|
|
29228
29228
|
__name(collectLogsHandler, "collectLogsHandler");
|
|
29229
|
+
function collectLogsBatchHandler(logDir, fileName) {
|
|
29230
|
+
const filePath = (0, import_path.join)(logDir, fileName);
|
|
29231
|
+
ensureDir(logDir);
|
|
29232
|
+
return async (req, res) => {
|
|
29233
|
+
try {
|
|
29234
|
+
const logContents = req.body;
|
|
29235
|
+
if (!Array.isArray(logContents)) {
|
|
29236
|
+
return res.status(400).json({
|
|
29237
|
+
message: "logContents must be an array"
|
|
29238
|
+
});
|
|
29239
|
+
}
|
|
29240
|
+
const logLines = [];
|
|
29241
|
+
for (const logContent of logContents) {
|
|
29242
|
+
logLines.push(JSON.stringify(logContent) + "\n");
|
|
29243
|
+
}
|
|
29244
|
+
await import_fs.default.promises.appendFile(filePath, logLines.join(""));
|
|
29245
|
+
res.json({
|
|
29246
|
+
success: true
|
|
29247
|
+
});
|
|
29248
|
+
} catch (error) {
|
|
29249
|
+
handleError2(res, error, "Failed to collect logs");
|
|
29250
|
+
}
|
|
29251
|
+
};
|
|
29252
|
+
}
|
|
29253
|
+
__name(collectLogsBatchHandler, "collectLogsBatchHandler");
|
|
29229
29254
|
function handleError2(res, error, message = "Failed to collect logs") {
|
|
29230
29255
|
res.status(500).json({
|
|
29231
29256
|
message,
|
|
@@ -29239,6 +29264,7 @@ function createDevLogRouter2(options = {}) {
|
|
|
29239
29264
|
const logDir = resolveLogDir2(options.logDir);
|
|
29240
29265
|
const router = import_express3.default.Router();
|
|
29241
29266
|
router.post("/collect", import_express3.default.json(), collectLogsHandler(logDir, options.fileName || "client.log"));
|
|
29267
|
+
router.post("/collect-batch", import_express3.default.json(), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
|
|
29242
29268
|
return router;
|
|
29243
29269
|
}
|
|
29244
29270
|
__name(createDevLogRouter2, "createDevLogRouter");
|