feat(loop): loop logları kalıcı hale getir
Loop loglarının dosya sistemine kaydedilmesi, okunması ve arşivlenmesi için yeni storage modülü eklendi. Loglar artık oturumlar arasında korunur. UI tarafında mobil menü iyileştirmeleri ve log paneli güncellemeleri yapıldı.
This commit is contained in:
@@ -4,6 +4,7 @@ import { readDb, writeDb } from "../storage/jsondb";
|
||||
import { nowIso } from "../utils/time";
|
||||
import { emitJobLog, emitJobMetrics } from "../realtime/emitter";
|
||||
import { appendAuditLog } from "../utils/logger";
|
||||
import { appendLoopLog } from "../storage/loopLogs";
|
||||
|
||||
const peerErrorThrottle = new Map<string, number>();
|
||||
|
||||
@@ -30,6 +31,12 @@ export const startEnforcementWorker = (intervalMs: number) => {
|
||||
message: "Peer listing unsupported; enforcement disabled",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
await appendLoopLog({
|
||||
jobId: job.id,
|
||||
level: "WARN",
|
||||
message: "Peer listing unsupported; enforcement disabled",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
continue;
|
||||
}
|
||||
let peersResponse;
|
||||
@@ -46,6 +53,12 @@ export const startEnforcementWorker = (intervalMs: number) => {
|
||||
message: "Peer listesi desteklenmiyor; enforcement devre dışı.",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
await appendLoopLog({
|
||||
jobId: job.id,
|
||||
level: "WARN",
|
||||
message: "Peer listesi desteklenmiyor; enforcement devre dışı.",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
peerErrorThrottle.set(job.id, Date.now());
|
||||
}
|
||||
continue;
|
||||
@@ -77,6 +90,12 @@ export const startEnforcementWorker = (intervalMs: number) => {
|
||||
message: `Banned ${banned.length} peers`,
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
await appendLoopLog({
|
||||
jobId: job.id,
|
||||
level: "WARN",
|
||||
message: `Banned ${banned.length} peers`,
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
await appendAuditLog({
|
||||
level: "WARN",
|
||||
event: "PEER_BANNED",
|
||||
@@ -91,6 +110,12 @@ export const startEnforcementWorker = (intervalMs: number) => {
|
||||
message: "Peer ban unsupported; warn-only enforcement",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
await appendLoopLog({
|
||||
jobId: job.id,
|
||||
level: "WARN",
|
||||
message: "Peer ban unsupported; warn-only enforcement",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
}
|
||||
|
||||
if (!allowIpConnected) {
|
||||
@@ -100,6 +125,12 @@ export const startEnforcementWorker = (intervalMs: number) => {
|
||||
message: "Allowed IP not connected",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
await appendLoopLog({
|
||||
jobId: job.id,
|
||||
level: "WARN",
|
||||
message: "Allowed IP not connected",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
}
|
||||
|
||||
job.updatedAt = nowIso();
|
||||
@@ -111,6 +142,12 @@ export const startEnforcementWorker = (intervalMs: number) => {
|
||||
message: "Enforcement error; continuing.",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
await appendLoopLog({
|
||||
jobId: job.id,
|
||||
level: "ERROR",
|
||||
message: "Enforcement error; continuing.",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user