Log errors/warnings to the console always

This commit is contained in:
Manav Rathi 2024-05-10 11:00:13 +05:30
parent 19d5d08d74
commit 1b3e11f713
No known key found for this signature in database
2 changed files with 9 additions and 10 deletions

View file

@ -62,7 +62,7 @@ const logError = (message: string, e?: unknown) => {
const logError_ = (message: string) => {
log.error(`[main] [error] ${message}`);
if (isDev) console.error(`[error] ${message}`);
console.error(`[error] ${message}`);
};
const logInfo = (...params: unknown[]) => {
@ -96,8 +96,8 @@ export default {
* any arbitrary object that we obtain, say, when in a try-catch handler (in
* JavaScript any arbitrary value can be thrown).
*
* The log is written to disk. In development builds, the log is also
* printed to the main (Node.js) process console.
* The log is written to disk and printed to the main (Node.js) process's
* console.
*/
error: logError,
/**
@ -120,7 +120,7 @@ export default {
* The function can return an arbitrary value which is serialized before
* being logged.
*
* This log is NOT written to disk. And it is printed to the main (Node.js)
* This log is NOT written to disk. It is printed to the main (Node.js)
* process console, but only on development builds.
*/
debug: logDebug,

View file

@ -45,13 +45,13 @@ const messageWithError = (message: string, e?: unknown) => {
const logError = (message: string, e?: unknown) => {
const m = `[error] ${messageWithError(message, e)}`;
if (isDevBuild) console.error(m);
console.error(m);
logToDisk(m);
};
const logWarn = (message: string, e?: unknown) => {
const m = `[warn] ${messageWithError(message, e)}`;
if (isDevBuild) console.error(m);
console.error(m);
logToDisk(m);
};
@ -89,8 +89,7 @@ export default {
* any arbitrary object that we obtain, say, when in a try-catch handler (in
* JavaScript any arbitrary value can be thrown).
*
* The log is written to disk. In development builds, the log is also
* printed to the browser console.
* The log is written to disk and printed to the browser console.
*/
error: logError,
/**
@ -118,8 +117,8 @@ export default {
* The function can return an arbitrary value which is serialized before
* being logged.
*
* This log is NOT written to disk. And it is printed to the browser
* console, but only in development builds.
* This log is NOT written to disk. It is printed to the browser console,
* but only in development builds.
*/
debug: logDebug,
};