refactor: standardize channel logging

This commit is contained in:
Peter Steinberger
2026-01-23 23:20:07 +00:00
parent 07ce1d73ff
commit aeb6b2ffad
16 changed files with 212 additions and 45 deletions

33
src/channels/logging.ts Normal file
View File

@@ -0,0 +1,33 @@
export type LogFn = (message: string) => void;
export function logInboundDrop(params: {
log: LogFn;
channel: string;
reason: string;
target?: string;
}): void {
const target = params.target ? ` target=${params.target}` : "";
params.log(`${params.channel}: drop ${params.reason}${target}`);
}
export function logTypingFailure(params: {
log: LogFn;
channel: string;
target?: string;
action?: "start" | "stop";
error: unknown;
}): void {
const target = params.target ? ` target=${params.target}` : "";
const action = params.action ? ` action=${params.action}` : "";
params.log(`${params.channel} typing${action} failed${target}: ${String(params.error)}`);
}
export function logAckFailure(params: {
log: LogFn;
channel: string;
target?: string;
error: unknown;
}): void {
const target = params.target ? ` target=${params.target}` : "";
params.log(`${params.channel} ack cleanup failed${target}: ${String(params.error)}`);
}