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

Debug option to enable logging server calls #17956

Merged
merged 5 commits into from
Sep 27, 2023

Conversation

karwosts
Copy link
Contributor

Proposed change

In another PR we mused about a "debug" section of developer tools. I use heavily the logger which reports calls between the frontend and the HA server in debugging. If possible, thought it would be nice to have an option to enable this in release mode, and it seemed like a fit for this section. There are times when it could help debug issues.

Note I'm not actually confident if this works at all, perhaps something about the way the release is compiled will make this impossible, though it seems to work as intended when I try it in the dev build. So just wanted to get some feedback on if this seems possible.

image

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@github-actions github-actions bot added Demo Related to frontend demo content Design Related to Home Assistant design gallery labels Sep 18, 2023
@bramkragten
Copy link
Member

This should just work! Wonder if we use log it in the console or make it visible on the screen, but for a first version, this seems perfect.

This will btw not log everything, it only logs the things that are called through the hass object, we also use connection directly to send messages, like subscriptions.

@karwosts
Copy link
Contributor Author

I like the console because it has a lot more features than just displaying a log. E.g. if you receive a response with 1000 entries in it, you can copy it as a javascript object, and run things like filter and map commands on it right in the console.

This will btw not log everything, it only logs the things that are called through the hass object, we also use connection directly to send messages, like subscriptions.

Yeah I noticed that not all data is captured this way (even in DEV mode), I'd like to log those type of connections someday if possible too.

@bramkragten
Copy link
Member

Had a quick discussion with the design team about the debug panel in the dev tools, and we think placing it in an overflow menu makes the most sense, as it doesn't matches the other panels in dev tools. They can be used by the average user and this is really for developers.

@@ -73,13 +73,14 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
translationMetadata,
dockedSidebar: "docked",
vibrate: true,
debugConnection: false,
Copy link
Member

Choose a reason for hiding this comment

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

I think we should store this in localStorage, now you will never be able to catch things when the page is refreshed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does including this in ha-pref-storage take care of that? I thought it was working when I tested it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like I'm getting everything I expect to see when hitting refresh with this toggle enabled (and I did remove the DEV part of the equation just to test and be sure).

image

Copy link
Member

Choose a reason for hiding this comment

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

Oh right, missed that 🙈 yeah pref storage stores that part in local storage!

@karwosts
Copy link
Contributor Author

Had a quick discussion with the design team about the debug panel in the dev tools, and we think placing it in an overflow menu makes the most sense, as it doesn't matches the other panels in dev tools. They can be used by the average user and this is really for developers.

You mean something like this?

image

@bramkragten
Copy link
Member

You mean something like this?

Yes, but in the top bar, so on the same height as Developer tools

@karwosts
Copy link
Contributor Author

Moved navigation to overflow.

image

@bramkragten bramkragten merged commit ad51d31 into home-assistant:dev Sep 27, 2023
8 checks passed
@karwosts karwosts deleted the frontend-debug-connection branch September 27, 2023 13:26
@github-actions github-actions bot locked and limited conversation to collaborators Sep 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed Demo Related to frontend demo content Design Related to Home Assistant design gallery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants