Send edited messages support
Co-authored-by: Fedor Indutnyy <indutny@signal.org>
This commit is contained in:
parent
d380817a44
commit
1f2cde6d04
79 changed files with 2507 additions and 1175 deletions
20
ts/util/timeAndLogIfTooLong.ts
Normal file
20
ts/util/timeAndLogIfTooLong.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import * as log from '../logging/log';
|
||||
|
||||
export async function timeAndLogIfTooLong(
|
||||
threshold: number,
|
||||
func: () => Promise<unknown>,
|
||||
getLogLine: (duration: number) => string
|
||||
): Promise<void> {
|
||||
const start = Date.now();
|
||||
try {
|
||||
await func();
|
||||
} finally {
|
||||
const duration = Date.now() - start;
|
||||
if (duration > threshold) {
|
||||
log.info(getLogLine(duration));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue