Import log instead of using it off of window
This commit is contained in:
parent
8eb0dd3116
commit
65ddf0a9e8
155 changed files with 3654 additions and 3433 deletions
|
@ -1,6 +1,8 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import * as log from '../logging/log';
|
||||
|
||||
export async function longRunningTaskWrapper<T>({
|
||||
name,
|
||||
idForLogging,
|
||||
|
@ -19,7 +21,7 @@ export async function longRunningTaskWrapper<T>({
|
|||
let progressView: Backbone.View | undefined;
|
||||
let spinnerStart;
|
||||
let progressTimeout: NodeJS.Timeout | undefined = setTimeout(() => {
|
||||
window.log.info(`longRunningTaskWrapper/${idLog}: Creating spinner`);
|
||||
log.info(`longRunningTaskWrapper/${idLog}: Creating spinner`);
|
||||
|
||||
// Note: this component uses a portal to render itself into the top-level DOM. No
|
||||
// need to attach it to the DOM here.
|
||||
|
@ -33,11 +35,9 @@ export async function longRunningTaskWrapper<T>({
|
|||
// Note: any task we put here needs to have its own safety valve; this function will
|
||||
// show a spinner until it's done
|
||||
try {
|
||||
window.log.info(`longRunningTaskWrapper/${idLog}: Starting task`);
|
||||
log.info(`longRunningTaskWrapper/${idLog}: Starting task`);
|
||||
const result = await task();
|
||||
window.log.info(
|
||||
`longRunningTaskWrapper/${idLog}: Task completed successfully`
|
||||
);
|
||||
log.info(`longRunningTaskWrapper/${idLog}: Task completed successfully`);
|
||||
|
||||
if (progressTimeout) {
|
||||
clearTimeout(progressTimeout);
|
||||
|
@ -46,7 +46,7 @@ export async function longRunningTaskWrapper<T>({
|
|||
if (progressView) {
|
||||
const now = Date.now();
|
||||
if (spinnerStart && now - spinnerStart < ONE_SECOND) {
|
||||
window.log.info(
|
||||
log.info(
|
||||
`longRunningTaskWrapper/${idLog}: Spinner shown for less than second, showing for another second`
|
||||
);
|
||||
await window.Signal.Util.sleep(ONE_SECOND);
|
||||
|
@ -57,7 +57,7 @@ export async function longRunningTaskWrapper<T>({
|
|||
|
||||
return result;
|
||||
} catch (error) {
|
||||
window.log.error(
|
||||
log.error(
|
||||
`longRunningTaskWrapper/${idLog}: Error!`,
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
|
@ -72,7 +72,7 @@ export async function longRunningTaskWrapper<T>({
|
|||
}
|
||||
|
||||
if (!suppressErrorDialog) {
|
||||
window.log.info(`longRunningTaskWrapper/${idLog}: Showing error dialog`);
|
||||
log.info(`longRunningTaskWrapper/${idLog}: Showing error dialog`);
|
||||
|
||||
// Note: this component uses a portal to render itself into the top-level DOM. No
|
||||
// need to attach it to the DOM here.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue