refactor: standardize channel logging
This commit is contained in:
33
src/channels/logging.ts
Normal file
33
src/channels/logging.ts
Normal 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)}`);
|
||||
}
|
||||
Reference in New Issue
Block a user