log.warn
This commit is contained in:
@@ -77,7 +77,7 @@ export const ffmpegExec = async (
|
||||
if (isInputFileTemporary) await deleteTempFile(inputFilePath);
|
||||
await deleteTempFile(outputFilePath);
|
||||
} catch (e) {
|
||||
log.error("Ignoring error when cleaning up temp files", e);
|
||||
log.error("Could not clean up temp files", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ export const convertToJPEG = async (imageData: Uint8Array) => {
|
||||
await deleteTempFile(inputFilePath);
|
||||
await deleteTempFile(outputFilePath);
|
||||
} catch (e) {
|
||||
log.error("Ignoring error when cleaning up temp files", e);
|
||||
log.error("Could not clean up temp files", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -110,7 +110,7 @@ export const generateImageThumbnail = async (
|
||||
if (isInputFileTemporary) await deleteTempFile(inputFilePath);
|
||||
await deleteTempFile(outputFilePath);
|
||||
} catch (e) {
|
||||
log.error("Ignoring error when cleaning up temp files", e);
|
||||
log.error("Could not clean up temp files", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -586,9 +586,7 @@ class UploadManager {
|
||||
) {
|
||||
try {
|
||||
let decryptedFile: EnteFile;
|
||||
log.info(
|
||||
`post upload action -> fileUploadResult: ${fileUploadResult} uploadedFile present ${!!uploadedFile}`,
|
||||
);
|
||||
log.info(`Upload completed with result: ${fileUploadResult}`);
|
||||
await this.removeFromPendingUploads(fileWithCollection);
|
||||
switch (fileUploadResult) {
|
||||
case UPLOAD_RESULT.FAILED:
|
||||
@@ -614,7 +612,9 @@ class UploadManager {
|
||||
// no-op
|
||||
break;
|
||||
default:
|
||||
throw Error("Invalid Upload Result" + fileUploadResult);
|
||||
throw new Error(
|
||||
`Invalid Upload Result ${fileUploadResult}`,
|
||||
);
|
||||
}
|
||||
if (
|
||||
[
|
||||
@@ -631,7 +631,7 @@ class UploadManager {
|
||||
fileWithCollection.livePhotoAssets.image,
|
||||
});
|
||||
} catch (e) {
|
||||
log.error("Error in fileUploaded handlers", e);
|
||||
log.warn("Ignoring error in fileUploaded handlers", e);
|
||||
}
|
||||
this.updateExistingFiles(decryptedFile);
|
||||
}
|
||||
|
||||
@@ -27,27 +27,30 @@ const workerLogToDisk = (message: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
const logError = (message: string, e?: unknown) => {
|
||||
if (!e) {
|
||||
logError_(message);
|
||||
return;
|
||||
}
|
||||
const messageWithError = (message: string, e?: unknown) => {
|
||||
if (!e) return message;
|
||||
|
||||
let es: string;
|
||||
if (e instanceof Error) {
|
||||
// In practice, we expect ourselves to be called with Error objects, so
|
||||
// this is the happy path so to say.
|
||||
es = `${e.name}: ${e.message}\n${e.stack}`;
|
||||
return `${e.name}: ${e.message}\n${e.stack}`;
|
||||
} else {
|
||||
// For the rest rare cases, use the default string serialization of e.
|
||||
es = String(e);
|
||||
}
|
||||
|
||||
logError_(`${message}: ${es}`);
|
||||
return `${message}: ${es}`;
|
||||
};
|
||||
|
||||
const logError_ = (message: string) => {
|
||||
const m = `[error] ${message}`;
|
||||
const logError = (message: string, e?: unknown) => {
|
||||
const m = `[error] ${messageWithError(message, e)}`;
|
||||
if (isDevBuild) console.error(m);
|
||||
logToDisk(m);
|
||||
};
|
||||
|
||||
const logWarn = (message: string, e?: unknown) => {
|
||||
const m = `[warn] ${messageWithError(message, e)}`;
|
||||
if (isDevBuild) console.error(m);
|
||||
logToDisk(m);
|
||||
};
|
||||
@@ -90,6 +93,11 @@ export default {
|
||||
* printed to the browser console.
|
||||
*/
|
||||
error: logError,
|
||||
/**
|
||||
* Sibling of {@link error}, with the same parameters and behaviour, except
|
||||
* it gets prefixed with a warning instead of an error tag.
|
||||
*/
|
||||
warn: logWarn,
|
||||
/**
|
||||
* Log a message.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user