Skip to content

Commit

Permalink
fix(mobile): moved debug logging to desktop only
Browse files Browse the repository at this point in the history
  • Loading branch information
iOSonntag committed Oct 6, 2023
1 parent ddb0fb5 commit f4adaa9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/util/logger.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Platform } from 'obsidian';
import { PluginInfo } from 'src/core/plugin-info';



export class Log {

/**
* Logs only if `process.env.NODE_ENV !== 'production'`.
* Logs only if `Platform.isDesktopApp` and if available `process.env.NODE_ENV !== 'production'`.
*
* Adds useful information to the log message and then logs it using `console.log`.
*
Expand All @@ -14,10 +15,16 @@ export class Log {
*/
static debug(message: string, ...args: any[])
{
if (process.env.NODE_ENV === 'production') return;
if (Platform.isDesktopApp)
{
// in case it is unknown we assume production, even though it is not correct
// it serves the purpose of not logging, when not in dev mode.


console.log(`[DEBUG][${PluginInfo.pluginId}]: ${message}`, ...args);
if ((process?.env?.NODE_ENV ?? 'production') !== 'production')
{
console.log(`[DEBUG][${PluginInfo.pluginId}]: ${message}`, ...args);
}
}
}


Expand Down

0 comments on commit f4adaa9

Please sign in to comment.