@hasna/logs 0.3.1 → 0.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/dist/cli/index.js +18 -11
- package/dist/export-c3eqjste.js +10 -0
- package/dist/health-9792c1rc.js +8 -0
- package/dist/index-fzmz9aqs.js +1241 -0
- package/dist/index-re3ntm60.js +48 -0
- package/dist/index-xjn8gam3.js +39 -0
- package/dist/jobs-ypmmc2ma.js +22 -0
- package/dist/mcp/index.js +2 -2
- package/dist/query-shjjj67k.js +14 -0
- package/dist/server/index.js +3 -3
- package/package.json +5 -1
- package/src/cli/index.ts +17 -7
package/dist/cli/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
import {
|
|
4
4
|
runJob
|
|
5
|
-
} from "../index-
|
|
5
|
+
} from "../index-fzmz9aqs.js";
|
|
6
6
|
import {
|
|
7
7
|
createPage,
|
|
8
8
|
createProject,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
__commonJS,
|
|
25
25
|
__require,
|
|
26
26
|
__toESM
|
|
27
|
-
} from "../index-
|
|
27
|
+
} from "../index-re3ntm60.js";
|
|
28
28
|
|
|
29
29
|
// node_modules/commander/lib/error.js
|
|
30
30
|
var require_error = __commonJS((exports) => {
|
|
@@ -2235,7 +2235,7 @@ program2.command("scan").description("Run an immediate scan for a job").option("
|
|
|
2235
2235
|
process.exit(1);
|
|
2236
2236
|
}
|
|
2237
2237
|
const db = getDb();
|
|
2238
|
-
const job = (await import("../jobs-
|
|
2238
|
+
const job = (await import("../jobs-ypmmc2ma.js")).getJob(db, opts.job);
|
|
2239
2239
|
if (!job) {
|
|
2240
2240
|
console.error("Job not found");
|
|
2241
2241
|
process.exit(1);
|
|
@@ -2244,9 +2244,15 @@ program2.command("scan").description("Run an immediate scan for a job").option("
|
|
|
2244
2244
|
await runJob(db, job.id, job.project_id, job.page_id ?? undefined);
|
|
2245
2245
|
console.log("Scan complete.");
|
|
2246
2246
|
});
|
|
2247
|
-
program2.command("watch").description("Stream new logs in real time with color coding").option("--project <id>").option("--level <levels>", "Comma-separated levels").option("--service <name>").action(async (opts) => {
|
|
2247
|
+
program2.command("watch").description("Stream new logs in real time with color coding").option("--project <name|id>", "Filter by project name or ID").option("--level <levels>", "Comma-separated levels (debug,info,warn,error,fatal)").option("--service <name>", "Filter by service name").option("--interval <ms>", "Poll interval in milliseconds (default: 500)", "500").option("--since <time>", "Start from this time (default: now)").action(async (opts) => {
|
|
2248
2248
|
const db = getDb();
|
|
2249
|
-
const { searchLogs: searchLogs2 } = await import("../query-
|
|
2249
|
+
const { searchLogs: searchLogs2 } = await import("../query-shjjj67k.js");
|
|
2250
|
+
let projectId = opts.project;
|
|
2251
|
+
if (projectId) {
|
|
2252
|
+
const proj = db.query("SELECT id FROM projects WHERE id = ? OR name = ?").get(projectId, projectId);
|
|
2253
|
+
if (proj)
|
|
2254
|
+
projectId = proj.id;
|
|
2255
|
+
}
|
|
2250
2256
|
const COLORS = {
|
|
2251
2257
|
debug: "\x1B[90m",
|
|
2252
2258
|
info: "\x1B[36m",
|
|
@@ -2256,15 +2262,16 @@ program2.command("watch").description("Stream new logs in real time with color c
|
|
|
2256
2262
|
};
|
|
2257
2263
|
const RESET = "\x1B[0m";
|
|
2258
2264
|
const BOLD = "\x1B[1m";
|
|
2259
|
-
let lastTimestamp = new Date().toISOString();
|
|
2265
|
+
let lastTimestamp = opts.since ? new Date(opts.since).toISOString() : new Date().toISOString();
|
|
2260
2266
|
let errorCount = 0;
|
|
2261
2267
|
let warnCount = 0;
|
|
2268
|
+
const pollIntervalMs = Math.max(100, Number(opts.interval) || 500);
|
|
2262
2269
|
process.stdout.write(`\x1B[2J\x1B[H`);
|
|
2263
|
-
console.log(`${BOLD}@hasna/logs watch${RESET} \u2014 Ctrl+C to exit
|
|
2270
|
+
console.log(`${BOLD}@hasna/logs watch${RESET} \u2014 Ctrl+C to exit${projectId ? ` [project: ${opts.project}]` : ""}
|
|
2264
2271
|
`);
|
|
2265
2272
|
const poll = () => {
|
|
2266
2273
|
const rows = searchLogs2(db, {
|
|
2267
|
-
project_id:
|
|
2274
|
+
project_id: projectId,
|
|
2268
2275
|
level: opts.level ? opts.level.split(",") : undefined,
|
|
2269
2276
|
service: opts.service,
|
|
2270
2277
|
since: lastTimestamp,
|
|
@@ -2286,7 +2293,7 @@ program2.command("watch").description("Stream new logs in real time with color c
|
|
|
2286
2293
|
}
|
|
2287
2294
|
process.stdout.write(`\x1B]2;logs: ${errorCount}E ${warnCount}W\x07`);
|
|
2288
2295
|
};
|
|
2289
|
-
const interval = setInterval(poll,
|
|
2296
|
+
const interval = setInterval(poll, pollIntervalMs);
|
|
2290
2297
|
process.on("SIGINT", () => {
|
|
2291
2298
|
clearInterval(interval);
|
|
2292
2299
|
console.log(`
|
|
@@ -2296,7 +2303,7 @@ Errors: ${errorCount} Warnings: ${warnCount}`);
|
|
|
2296
2303
|
});
|
|
2297
2304
|
});
|
|
2298
2305
|
program2.command("export").description("Export logs to JSON or CSV").option("--project <id>").option("--since <time>", "Relative time or ISO").option("--level <level>").option("--service <name>").option("--format <fmt>", "json or csv", "json").option("--output <file>", "Output file (default: stdout)").option("--limit <n>", "Max rows", "100000").action(async (opts) => {
|
|
2299
|
-
const { exportToCsv, exportToJson } = await import("../export-
|
|
2306
|
+
const { exportToCsv, exportToJson } = await import("../export-c3eqjste.js");
|
|
2300
2307
|
const { createWriteStream } = await import("fs");
|
|
2301
2308
|
const db = getDb();
|
|
2302
2309
|
const options = {
|
|
@@ -2322,7 +2329,7 @@ Exported ${count} log(s)
|
|
|
2322
2329
|
}
|
|
2323
2330
|
});
|
|
2324
2331
|
program2.command("health").description("Show server health and DB stats").action(async () => {
|
|
2325
|
-
const { getHealth } = await import("../health-
|
|
2332
|
+
const { getHealth } = await import("../health-9792c1rc.js");
|
|
2326
2333
|
const h = getHealth(getDb());
|
|
2327
2334
|
console.log(JSON.stringify(h, null, 2));
|
|
2328
2335
|
});
|