File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { Platform } from 'obsidian' ;
12import { PluginInfo } from 'src/core/plugin-info' ;
23
34
45
56export class Log {
67
78 /**
8- * Logs only if `process.env.NODE_ENV !== 'production'`.
9+ * Logs only if `Platform.isDesktopApp` and if available ` process.env.NODE_ENV !== 'production'`.
910 *
1011 * Adds useful information to the log message and then logs it using `console.log`.
1112 *
@@ -14,10 +15,16 @@ export class Log {
1415 */
1516 static debug ( message : string , ...args : any [ ] )
1617 {
17- if ( process . env . NODE_ENV === 'production' ) return ;
18+ if ( Platform . isDesktopApp )
19+ {
20+ // in case it is unknown we assume production, even though it is not correct
21+ // it serves the purpose of not logging, when not in dev mode.
1822
19-
20- console . log ( `[DEBUG][${ PluginInfo . pluginId } ]: ${ message } ` , ...args ) ;
23+ if ( ( process ?. env ?. NODE_ENV ?? 'production' ) !== 'production' )
24+ {
25+ console . log ( `[DEBUG][${ PluginInfo . pluginId } ]: ${ message } ` , ...args ) ;
26+ }
27+ }
2128 }
2229
2330
You can’t perform that action at this time.
0 commit comments