diff options
Diffstat (limited to 'src/utils/logger.ts')
-rw-r--r-- | src/utils/logger.ts | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 2d3a1b92..8e9928b5 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -1,12 +1,22 @@ -window["SBLogs"] = { - debug: [], - warn: [] -}; +if (typeof (window) !== "undefined") { + window["SBLogs"] = { + debug: [], + warn: [] + }; +} export function logDebug(message: string) { - window["SBLogs"].debug.push(`[${new Date().toISOString()}] ${message}`); + if (typeof (window) !== "undefined") { + window["SBLogs"].debug.push(`[${new Date().toISOString()}] ${message}`); + } else { + console.log(`[${new Date().toISOString()}] ${message}`) + } } export function logWarn(message: string) { - window["SBLogs"].warn.push(`[${new Date().toISOString()}] ${message}`); + if (typeof (window) !== "undefined") { + window["SBLogs"].warn.push(`[${new Date().toISOString()}] ${message}`); + } else { + console.warn(`[${new Date().toISOString()}] ${message}`) + } }
\ No newline at end of file |