mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 13:01:42 +03:00
refactor: standardize channel logging
This commit is contained in:
@@ -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