Skip to content

Add debug log message to print each bar's widget tree #927

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

Merged
merged 3 commits into from
Dec 1, 2020

Conversation

tchebb
Copy link
Contributor

@tchebb tchebb commented Nov 30, 2020

This is very useful when writing CSS that affects more than just a single widget. Pass -l debug to enable debug logging and show this information.

Example output:

[2020-11-30 12:38:51.141] [debug] GTK widget tree:
window#waybar.background.bottom.eDP-1.:dir(ltr)
  decoration:dir(ltr)
  box.horizontal:dir(ltr)
    box.horizontal.modules-left:dir(ltr)
      widget:dir(ltr)
        box#workspaces.horizontal:dir(ltr)
      widget:dir(ltr)
        label#mode:dir(ltr)
      widget:dir(ltr)
        label#window:dir(ltr)
    box.horizontal.modules-center:dir(ltr)
    box.horizontal.modules-right:dir(ltr)
      widget:dir(ltr)
        box#tray.horizontal:dir(ltr)
      widget:dir(ltr)
        label#idle_inhibitor:dir(ltr)
      widget:dir(ltr)
        label#pulseaudio:dir(ltr)
      widget:dir(ltr)
        label#network:dir(ltr)
      widget:dir(ltr)
        label#cpu:dir(ltr)
      widget:dir(ltr)
        label#memory:dir(ltr)
      widget:dir(ltr)
        label#temperature:dir(ltr)
      widget:dir(ltr)
        label#backlight:dir(ltr)
      widget:dir(ltr)
        label#battery:dir(ltr)
      widget:dir(ltr)
        label#clock:dir(ltr)

spdlog bundles a version of fmt. However, we also depend on and use fmt
directly. If we don't tell spdlog not to use its bundled version, we end
up with two versions of fmt in our include path, since both libraries
are header-only, meaning any slight API mismatches will cause build
failures and undesired behavior.

We seem to have gotten lucky so far, but I ran into all sorts of issues
when I tried to update to a newer version of spdlog. This change
prevents them.
Among other changes, this adds spdlog::should_log(), which lets us
easily determine whether a log message will be printed so that we can
avoid extra computation when unnecessary.

New wrap file taken from https://wrapdb.mesonbuild.com/spdlog and
modified to download from GitHub as per commit 99dde1a ("Download
patch files from Github instead of wrapdb").
This is very useful when writing CSS that affects more than just a
single widget. Pass `-l debug` to enable debug logging and show this
information.

Example output:

    [2020-11-30 12:38:51.141] [debug] GTK widget tree:
    window#waybar.background.bottom.eDP-1.:dir(ltr)
      decoration:dir(ltr)
      box.horizontal:dir(ltr)
        box.horizontal.modules-left:dir(ltr)
          widget:dir(ltr)
            box#workspaces.horizontal:dir(ltr)
          widget:dir(ltr)
            label#mode:dir(ltr)
          widget:dir(ltr)
            label#window:dir(ltr)
        box.horizontal.modules-center:dir(ltr)
        box.horizontal.modules-right:dir(ltr)
          widget:dir(ltr)
            box#tray.horizontal:dir(ltr)
          widget:dir(ltr)
            label#idle_inhibitor:dir(ltr)
          widget:dir(ltr)
            label#pulseaudio:dir(ltr)
          widget:dir(ltr)
            label#network:dir(ltr)
          widget:dir(ltr)
            label#cpu:dir(ltr)
          widget:dir(ltr)
            label#memory:dir(ltr)
          widget:dir(ltr)
            label#temperature:dir(ltr)
          widget:dir(ltr)
            label#backlight:dir(ltr)
          widget:dir(ltr)
            label#battery:dir(ltr)
          widget:dir(ltr)
            label#clock:dir(ltr)
@tchebb
Copy link
Contributor Author

tchebb commented Dec 1, 2020

Updated with commits that bump the bundled spdlog version, since the one we had previously doesn't have spdlog::should_log(). This should fix the CI failures.

@Alexays Alexays merged commit 881bb62 into Alexays:master Dec 1, 2020
@Alexays
Copy link
Owner

Alexays commented Dec 1, 2020

Thanks, useful!

@Alexays
Copy link
Owner

Alexays commented Dec 1, 2020

Maybe, add a sentence to the github wiki about this?

@tchebb tchebb deleted the log-gtk-tree branch December 1, 2020 11:46
@tchebb
Copy link
Contributor Author

tchebb commented Dec 1, 2020

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.

2 participants