-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intercept matrix_sdk logging via console and include in rageshake #2623
base: livekit
Are you sure you want to change the base?
Conversation
( | ||
["trace", "debug", "info", "warn", "error"] as ( | ||
| "trace" | ||
| "debug" | ||
| "info" | ||
| "warn" | ||
| "error" | ||
)[] | ||
).forEach((level) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is slightly less nasty:
( | |
["trace", "debug", "info", "warn", "error"] as ( | |
| "trace" | |
| "debug" | |
| "info" | |
| "warn" | |
| "error" | |
)[] | |
).forEach((level) => { | |
[ | |
"trace" as const, | |
"debug" as const, | |
"info" as const, | |
"warn" as const, | |
"error" as const, | |
].forEach((level) => { |
And thank https://typescript-eslint.io/rules/prefer-as-const/ for teaching me about "as const" 😃
if (!window.console[level]) return; | ||
const prefix = `${level.toUpperCase()} matrix_sdk`; | ||
const originalMethod = window.console[level]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, rearrange some lines to avoid a redundant lookup on window.console
if (!window.console[level]) return; | |
const prefix = `${level.toUpperCase()} matrix_sdk`; | |
const originalMethod = window.console[level]; | |
const originalMethod = window.console[level]; | |
if (!originalMethod) return; | |
const prefix = `${level.toUpperCase()} matrix_sdk`; |
window.console[level] = (...args): void => { | ||
originalMethod(...args); | ||
if (typeof args[0] === "string" && args[0].startsWith(prefix)) { | ||
global.mx_rage_logger.log(LogLevel[level], "matrix_sdk", ...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is passing the entire args
array intentional, or should args[0]
(i.e. the argument with the prefix) be excluded?
No description provided.