fix(logging): trim provider log prefixes
This commit is contained in:
@@ -94,11 +94,11 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
|
||||
const guildHistories = new Map<string, DiscordHistoryEntry[]>();
|
||||
|
||||
client.once(Events.ClientReady, () => {
|
||||
runtime.log?.(`discord: logged in as ${client.user?.tag ?? "unknown"}`);
|
||||
runtime.log?.(`logged in as ${client.user?.tag ?? "unknown"}`);
|
||||
});
|
||||
|
||||
client.on(Events.Error, (err) => {
|
||||
runtime.error?.(danger(`discord client error: ${String(err)}`));
|
||||
runtime.error?.(danger(`client error: ${String(err)}`));
|
||||
});
|
||||
|
||||
client.on(Events.MessageCreate, async (message) => {
|
||||
@@ -294,7 +294,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
|
||||
guildHistories.set(message.channelId, []);
|
||||
}
|
||||
} catch (err) {
|
||||
runtime.error?.(danger(`Discord handler failed: ${String(err)}`));
|
||||
runtime.error?.(danger(`handler failed: ${String(err)}`));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -427,6 +427,6 @@ async function deliverReplies({
|
||||
});
|
||||
}
|
||||
}
|
||||
runtime.log?.(`discord: delivered reply to ${target}`);
|
||||
runtime.log?.(`delivered reply to ${target}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ async function waitForSignalDaemonReady(params: {
|
||||
|
||||
params.runtime.error?.(
|
||||
danger(
|
||||
`signal: daemon not ready after ${params.timeoutMs}ms (${lastError ?? "unknown error"})`,
|
||||
`daemon not ready after ${params.timeoutMs}ms (${lastError ?? "unknown error"})`,
|
||||
),
|
||||
);
|
||||
throw new Error(`signal daemon not ready (${lastError ?? "unknown error"})`);
|
||||
@@ -207,7 +207,7 @@ async function deliverReplies(params: {
|
||||
});
|
||||
}
|
||||
}
|
||||
runtime.log?.(`signal: delivered reply to ${target}`);
|
||||
runtime.log?.(`delivered reply to ${target}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,13 +267,11 @@ export async function monitorSignalProvider(
|
||||
try {
|
||||
payload = JSON.parse(event.data) as SignalReceivePayload;
|
||||
} catch (err) {
|
||||
runtime.error?.(`signal: failed to parse event: ${String(err)}`);
|
||||
runtime.error?.(`failed to parse event: ${String(err)}`);
|
||||
return;
|
||||
}
|
||||
if (payload?.exception?.message) {
|
||||
runtime.error?.(
|
||||
`signal: receive exception: ${payload.exception.message}`,
|
||||
);
|
||||
runtime.error?.(`receive exception: ${payload.exception.message}`);
|
||||
}
|
||||
const envelope = payload?.envelope;
|
||||
if (!envelope) return;
|
||||
@@ -317,9 +315,7 @@ export async function monitorSignalProvider(
|
||||
fetched.contentType ?? firstAttachment.contentType ?? undefined;
|
||||
}
|
||||
} catch (err) {
|
||||
runtime.error?.(
|
||||
danger(`signal: attachment fetch failed: ${String(err)}`),
|
||||
);
|
||||
runtime.error?.(danger(`attachment fetch failed: ${String(err)}`));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +398,7 @@ export async function monitorSignalProvider(
|
||||
abortSignal: opts.abortSignal,
|
||||
onEvent: (event) => {
|
||||
void handleEvent(event).catch((err) => {
|
||||
runtime.error?.(`signal: event handler failed: ${String(err)}`);
|
||||
runtime.error?.(`event handler failed: ${String(err)}`);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -199,7 +199,7 @@ describe("telegram inbound media", () => {
|
||||
expect(replySpy).not.toHaveBeenCalled();
|
||||
expect(runtimeError).toHaveBeenCalledTimes(1);
|
||||
const msg = String(runtimeError.mock.calls[0]?.[0] ?? "");
|
||||
expect(msg).toContain("Telegram handler failed:");
|
||||
expect(msg).toContain("handler failed:");
|
||||
expect(msg).toContain("file_path");
|
||||
|
||||
fetchSpy.mockRestore();
|
||||
|
||||
@@ -201,7 +201,7 @@ export function createTelegramBot(opts: TelegramBotOptions) {
|
||||
bot,
|
||||
});
|
||||
} catch (err) {
|
||||
runtime.error?.(danger(`Telegram handler failed: ${String(err)}`));
|
||||
runtime.error?.(danger(`handler failed: ${String(err)}`));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -225,7 +225,7 @@ async function deliverReplies(params: {
|
||||
const { replies, chatId, runtime, bot } = params;
|
||||
for (const reply of replies) {
|
||||
if (!reply?.text && !reply?.mediaUrl && !(reply?.mediaUrls?.length ?? 0)) {
|
||||
runtime.error?.(danger("Telegram reply missing text/media"));
|
||||
runtime.error?.(danger("reply missing text/media"));
|
||||
continue;
|
||||
}
|
||||
const mediaList = reply.mediaUrls?.length
|
||||
|
||||
@@ -46,9 +46,7 @@ export async function startTelegramWebhook(opts: {
|
||||
const handled = handler(req, res);
|
||||
if (handled && typeof (handled as Promise<void>).catch === "function") {
|
||||
void (handled as Promise<void>).catch((err) => {
|
||||
runtime.log?.(
|
||||
`Telegram webhook handler failed: ${formatErrorMessage(err)}`,
|
||||
);
|
||||
runtime.log?.(`webhook handler failed: ${formatErrorMessage(err)}`);
|
||||
if (!res.headersSent) res.writeHead(500);
|
||||
res.end();
|
||||
});
|
||||
@@ -64,7 +62,7 @@ export async function startTelegramWebhook(opts: {
|
||||
});
|
||||
|
||||
await new Promise<void>((resolve) => server.listen(port, host, resolve));
|
||||
runtime.log?.(`Telegram webhook listening on ${publicUrl}`);
|
||||
runtime.log?.(`webhook listening on ${publicUrl}`);
|
||||
|
||||
const shutdown = () => {
|
||||
server.close();
|
||||
|
||||
Reference in New Issue
Block a user