-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make stats and client logs more easily accessible through slash commands
- Loading branch information
1 parent
2ec2ecb
commit da07424
Showing
7 changed files
with
146 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,54 @@ | ||
/* eslint-disable no-console */ | ||
|
||
import {STORAGE_CALLS_CLIENT_LOGS_KEY} from 'src/constants'; | ||
|
||
import {pluginId} from './manifest'; | ||
|
||
let clientLogs = ''; | ||
|
||
function appendClientLog(level: string, ...args: unknown[]) { | ||
clientLogs += `${level} [${new Date().toISOString()}] ${args}\n`; | ||
} | ||
|
||
export function persistClientLogs() { | ||
const storage = window.desktop ? localStorage : sessionStorage; | ||
storage.setItem(STORAGE_CALLS_CLIENT_LOGS_KEY, clientLogs); | ||
clientLogs = ''; | ||
} | ||
|
||
export function getClientLogs() { | ||
const storage = window.desktop ? localStorage : sessionStorage; | ||
return storage.getItem(STORAGE_CALLS_CLIENT_LOGS_KEY) || ''; | ||
} | ||
|
||
export function logErr(...args: unknown[]) { | ||
console.error(`${pluginId}:`, ...args); | ||
try { | ||
if (window.callsClient) { | ||
appendClientLog('error', ...args); | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
|
||
export function logWarn(...args: unknown[]) { | ||
console.warn(`${pluginId}:`, ...args); | ||
if (window.callsClient) { | ||
appendClientLog('warn', ...args); | ||
} | ||
} | ||
|
||
export function logInfo(...args: unknown[]) { | ||
console.info(`${pluginId}:`, ...args); | ||
if (window.callsClient) { | ||
appendClientLog('info', ...args); | ||
} | ||
} | ||
|
||
export function logDebug(...args: unknown[]) { | ||
// TODO: convert to debug once we are out of beta. | ||
console.info(`${pluginId}:`, ...args); | ||
console.debug(`${pluginId}:`, ...args); | ||
if (window.callsClient) { | ||
appendClientLog('debug', ...args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters