@lark-apaas/devtool-kits 0.1.0-alpha.7 → 0.1.0-alpha.9

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/dist/index.cjs CHANGED
@@ -29215,7 +29215,15 @@ function collectLogsHandler(logDir, fileName) {
29215
29215
  return async (req, res) => {
29216
29216
  try {
29217
29217
  const logContent = req.body;
29218
- const logLine = JSON.stringify(logContent) + "\n";
29218
+ if (!logContent.message) {
29219
+ return res.status(400).json({
29220
+ message: "message is required"
29221
+ });
29222
+ }
29223
+ const logLine = JSON.stringify({
29224
+ ...logContent,
29225
+ server_time: (/* @__PURE__ */ new Date()).toISOString()
29226
+ }) + "\n";
29219
29227
  await import_fs.default.promises.appendFile(filePath, logLine);
29220
29228
  res.json({
29221
29229
  success: true
@@ -29226,6 +29234,34 @@ function collectLogsHandler(logDir, fileName) {
29226
29234
  };
29227
29235
  }
29228
29236
  __name(collectLogsHandler, "collectLogsHandler");
29237
+ function collectLogsBatchHandler(logDir, fileName) {
29238
+ const filePath = (0, import_path.join)(logDir, fileName);
29239
+ ensureDir(logDir);
29240
+ return async (req, res) => {
29241
+ try {
29242
+ const logContents = req.body;
29243
+ if (!Array.isArray(logContents)) {
29244
+ return res.status(400).json({
29245
+ message: "logContents must be an array"
29246
+ });
29247
+ }
29248
+ const logLines = [];
29249
+ for (const logContent of logContents) {
29250
+ logLines.push(JSON.stringify({
29251
+ ...logContent,
29252
+ server_time: (/* @__PURE__ */ new Date()).toISOString()
29253
+ }) + "\n");
29254
+ }
29255
+ await import_fs.default.promises.appendFile(filePath, logLines.join(""));
29256
+ res.json({
29257
+ success: true
29258
+ });
29259
+ } catch (error) {
29260
+ handleError2(res, error, "Failed to collect logs");
29261
+ }
29262
+ };
29263
+ }
29264
+ __name(collectLogsBatchHandler, "collectLogsBatchHandler");
29229
29265
  function handleError2(res, error, message = "Failed to collect logs") {
29230
29266
  res.status(500).json({
29231
29267
  message,
@@ -29239,6 +29275,7 @@ function createDevLogRouter2(options = {}) {
29239
29275
  const logDir = resolveLogDir2(options.logDir);
29240
29276
  const router = import_express3.default.Router();
29241
29277
  router.post("/collect", import_express3.default.json(), collectLogsHandler(logDir, options.fileName || "client.log"));
29278
+ router.post("/collect-batch", import_express3.default.json(), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
29242
29279
  return router;
29243
29280
  }
29244
29281
  __name(createDevLogRouter2, "createDevLogRouter");