Browse Source

Log errors/warnings to the console always

Manav Rathi 1 year ago
parent
commit
1b3e11f713
2 changed files with 9 additions and 10 deletions
  1. 4 4
      desktop/src/main/log.ts
  2. 5 6
      web/packages/next/log.ts

+ 4 - 4
desktop/src/main/log.ts

@@ -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,

+ 5 - 6
web/packages/next/log.ts

@@ -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,
 };