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

Add logging of class and method names into Logger #22398

Merged
merged 2 commits into from
Aug 22, 2023

Conversation

nallikaea
Copy link
Contributor

@nallikaea nallikaea commented Jul 26, 2023

@che-bot che-bot added target/branch Indicates that a PR will be merged into a branch other than master. status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. labels Jul 26, 2023
@nallikaea nallikaea self-assigned this Jul 26, 2023
@dmytro-ndp
Copy link
Contributor

@nallikaea : it would be interesting to see how will error or warning message look like. Would you please share anyone?

@nallikaea
Copy link
Contributor Author

@nallikaea : it would be interesting to see how will error or warning message look like. Would you please share anyone?

https://github.com/eclipse/che/actions/runs/5925319878/job/16064524673

@dmytro-ndp
Copy link
Contributor

Thank you, @nallikaea

I had also triggered devspaces tests from this PR https://main-jenkins-csb-crwqe.apps.ocp-c1.prod.psi.redhat.com/job/Testing/job/e2e/job/basic/job/typescript-tests/11393/ and found lots of Context.<anonymous> - prefixes. IMHO, it makes sense to filter Context.<anonymous> - and leave just text message, e.g.:
Context.<anonymous> - editor.getText(): get recommended extensions as text from editor, delete comments and parse to object.
to replace with
Editor.getText(): get recommended extensions as text from editor, delete comments and parse to object..

Also, am I understand correctly, that next method call can't be identified automatically and so should be written up explicitly in the code? :

  • ActivityBar().getViewControl('Extensions'))?.openView()
  • Editor.getText()

@nallikaea
Copy link
Contributor Author

nallikaea commented Aug 22, 2023

@dmytro-ndp

  • Context is mocha class, it means that Logger was called inside mochas test function:
test(`Test name`, async function(): Promise<void> {
      Logger.debug(`some message`);

returns: Context.anonimus - some message

  • In case of hard-coded functions it because Logger was called before some function inside the test and says what gonna be next. It is impossible to put our Logger inside monaco-page-object library functions.
test(`Test name`, async function(): Promise<void> {
    Logger.debug(`EditorView().openEditor(${extensionsListFileName})`);
    const editor: TextEditor = await new EditorView().openEditor(extensionsListFileName) as TextEditor;

returns: Context.anonimus - EditorView().openEditor(${extensionsListFileName})

maybe we can delete it because monaco-page-object library has own logger and will tell us something in case of error.

const e: Error = new Error();
const stack: string[] = e.stack ? e.stack.split('\n') : [];
// " at functionName ( ..." => "functionName"
return stack[3].replace(/^\s+at\s+(.+?)\s.+/g, '$1');
Copy link
Contributor

Choose a reason for hiding this comment

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

What about don't logging Context.<anonymous> and Runner.<anonymous> to make log cleaner?

stack[3].replace(/^\s+at\s+(.+?)\s.+/g, '$1')
            .replace('Context.<anonymous>', '')
            .replace('Runner.<anonymous> ', '')

E.g.:

    ✔ Get recommended extensions list from extensions.json (10623ms)
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
     ✔ Open "Extensions" view section (1885ms)
       • Context.<anonymous> - Time for extensions installation TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT=30000
             ‣ DriverHelper.wait - (30000 milliseconds)
     ✔ Let extensions complete installation (30003ms)
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
           ▼ Context.<anonymous> - ActivityBar().getViewControl('Extensions'))?.openView(): open Extensions view.
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): get current section.
             ‣ DriverHelper.waitAllPresence - By(css selector, .name)
       • Context.<anonymous> - Check if {"publisher":"ms-python","name":"python"} are installed.
           ▼ Context.<anonymous> - extensionSection.findItem(python).
             ‣ DriverHelper.isVisible - By(xpath, //a[text()='Reload Required'])
           ▼ Context.<anonymous> - extensionsView?.getContent().getSections(): switch to marketplace section.
             ‣ DriverHelper.waitVisibility - By(css selector, .monaco-list-rows)
             ‣ DriverHelper.waitVisibility - element is located and is visible.
           ▼ Context.<anonymous> - marketplaceSection.getVisibleItems(): get all found items.
           ▼ Context.<anonymous> - Try to find extension published by ms-python.
           ▼ Context.<anonymous> - Extension was found: Black Formatter
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled()
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher?.isInstalled(): true.
           ▼ Context.<anonymous> - itemWithRightNameAndPublisher.manage(): get context menu.
     1) Check if extensions are installed and enabled
   [ERROR] Runner.<anonymous> - CheReporter runner.on.fail: Check if recommended extensions installed for Ansible Check if extensions are installed and enabled failed after 3346ms
             ‣ Runner.<anonymous> - FullTitle:Check if recommended extensions installed for Ansible Check if extensions are installed and enabled
             ‣ Runner.<anonymous> - FullTitleSanitized:Check_if_recommended_extensions_installed_for_Ansible_Check_if_extensions_are_installed_and_enabled
             ‣ Runner.<anonymous> - TestTitle:Check if extensions are installed and enabled
             ‣ Runner.<anonymous> - TestTitleSanitized:Check_if_extensions_are_installed_and_enabled
             ‣ DriverHelper.getDriver  

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nallikaea nallikaea merged commit 62c0c9d into eclipse-che:main Aug 22, 2023
2 checks passed
@che-bot che-bot removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Aug 22, 2023
@nallikaea nallikaea deleted the 22204 branch August 24, 2023 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed. target/branch Indicates that a PR will be merged into a branch other than master.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add logging of class and method names into Logger
4 participants