Skip to content
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

Improve debugging discoverability #2529

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

KangxuanYe
Copy link
Contributor

@KangxuanYe KangxuanYe commented Sep 26, 2024

For more information about how to contribute to this repo, visit this page.

Description

This is a PR to improve developers debugging experience.

In the past, developers need to turn on client logging following this document so that they can see the logs after app gets refreshed. It will request developers to select correct iframe, set verbose log level, type localStorage.debug = 'teamsJs.*' in console and then refresh the app to get logs from debugger.

With this PR, developers only need to set log level in browser as 'verbose' to see logs displayed by debugger. And they can write code as logger.turnOnDebugLogs() and logger.turnOffDebugLogs() to display the logs from debugger in a segment of code they are interested in.

One of use will be put logger.turnOnDebugLogs() before app.initialize() API call so that all of logs during initialization will be displayed on browser console.

logger.turnOnDebugLogs() and logger.turnOffDebugLogs() are to set a global variable to be true and false. With this global value, we created a wrapper over original debugger from debug npm library as topLevelLogger. If developers keep following our wiki, it will work as it is and we use debugger directly to display logs. Otherwise, if developers use API call to turn on debug logs, we call console.timeLog to display logs.

However, the experience of developers will be the same!

Main changes in the PR:

  1. Created a logger capability to turn on and off console logs by leveraging on global variable.
  2. Created logger capability in test app for testing purpose
  3. Created a function to wrap debugger in telemetry.ts

Validation

Validation performed:

  1. Please read PR description and run the test app for try out.

Unit Tests added: No

End-to-end tests added: No

@@ -12,7 +13,59 @@ registerLogger.formatArgs = function (args) {
originalFormatArgsFunction.call(this, args);
};

const topLevelLogger = registerLogger('teamsJs');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const createDebuggerFunction = (namespace: string): Debugger => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool and it will probably need a good dose of explanatory comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please take a look on comments? Basically I just explained the code in detail.

@KangxuanYe KangxuanYe force-pushed the kx/debugging_discoverability_poc branch from 2e98a63 to cf18306 Compare October 8, 2024 21:06
@KangxuanYe KangxuanYe marked this pull request as ready for review October 9, 2024 00:00
@KangxuanYe KangxuanYe requested a review from a team as a code owner October 9, 2024 00:00
@KangxuanYe KangxuanYe changed the title [DRAFT/DO NOT REVIEW] Kx/debugging discoverability poc Improve debugging discoverability Oct 9, 2024
@AE-MS
Copy link
Contributor

AE-MS commented Oct 9, 2024

This looks neat -- can you say more about the use-case for it? Is it something we expect customers might find easier to enable than the current set of logging steps? Or is it something you expect to be able to use when debugging issues? Etc.?

@KangxuanYe
Copy link
Contributor Author

This looks neat -- can you say more about the use-case for it? Is it something we expect customers might find easier to enable than the current set of logging steps? Or is it something you expect to be able to use when debugging issues? Etc.?

Based on our discussion with Saurabh, I think the use-case would be customers find the bug/error/failure in their code from Teams-Js library and they wish to know what happened. Then they can read the documentation of Logger capability and by calling APIs in their codebase, they can get all/partial of client debugging loggings depending on where they turn on the client debugging loggings. In this scenario, I think customers will have easier steps for debugging and have more control on which part they would like to focus on. They can use this method for debugging but for my work, I would still request them to follow the steps we have right now to make sure they send ALL of client loggings to me from the beginning of initialization.

@KangxuanYe KangxuanYe marked this pull request as draft October 14, 2024 22:45
@KangxuanYe
Copy link
Contributor Author

Need to turn it back to draft again because after rebasing on main, the console log complains that it cannot find timer, which is used by console.timeLog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants