-
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.
[MM-59996] Make stats and client logs more easily accessible through …
…slash commands (#840) * Make stats and client logs more easily accessible through slash commands * Util function * Command response wrapper * Fix e2e * Revert "Fix e2e" This reverts commit 7710471. * Use Playbooks v2
- Loading branch information
1 parent
d01f4db
commit 45ecd66
Showing
7 changed files
with
152 additions
and
60 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,53 @@ | ||
/* eslint-disable no-console */ | ||
|
||
import {STORAGE_CALLS_CLIENT_LOGS_KEY} from 'src/constants'; | ||
import {getPersistentStorage} from 'src/utils'; | ||
|
||
import {pluginId} from './manifest'; | ||
|
||
let clientLogs = ''; | ||
|
||
function appendClientLog(level: string, ...args: unknown[]) { | ||
clientLogs += `${level} [${new Date().toISOString()}] ${args}\n`; | ||
} | ||
|
||
export function persistClientLogs() { | ||
getPersistentStorage().setItem(STORAGE_CALLS_CLIENT_LOGS_KEY, clientLogs); | ||
clientLogs = ''; | ||
} | ||
|
||
export function getClientLogs() { | ||
return getPersistentStorage().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
Oops, something went wrong.