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

Log viewer: Fixed column width for timestamp, level & logger name #3011

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Jan 13, 2025

When using the log viewer, I have regularly noticed that the time column is wider than required, as well as the logger name column taking up much space and making the message column move if a new log with a longer logger name comes in.
This PR sets the width of the time, level and logger name columns to a fixed value and limits the logger name length to the last 40 chars, which is enough to identify the logger.

@florian-h05 florian-h05 requested a review from ghys as a code owner January 13, 2025 13:31
@florian-h05 florian-h05 force-pushed the logviewer-limit-column-width branch 2 times, most recently from 6c64709 to 876a56c Compare January 13, 2025 13:33
@florian-h05 florian-h05 changed the title Log viewer: Limit column width Log viewer: Fixed column width for timestamp, level & logger Jan 13, 2025
Copy link

relativeci bot commented Jan 13, 2025

#2721 Bundle Size — 10.98MiB (~+0.01%).

f8c86bb(current) vs bf2f2ee main#2718(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  no changes
                 Current
#2721
     Baseline
#2718
No change  Initial JS 1.9MiB 1.9MiB
No change  Initial CSS 577.21KiB 577.21KiB
No change  Cache Invalidation 17.39% 17.39%
No change  Chunks 227 227
No change  Assets 250 250
No change  Modules 2951 2951
No change  Duplicate Modules 154 154
No change  Duplicate Code 1.8% 1.8%
No change  Packages 98 98
No change  Duplicate Packages 2 2
Bundle size by type  Change 2 changes Regression 2 regressions
                 Current
#2721
     Baseline
#2718
Regression  JS 9.19MiB (~+0.01%) 9.19MiB
Regression  CSS 867.25KiB (+0.02%) 867.06KiB
No change  Fonts 526.1KiB 526.1KiB
No change  Media 295.6KiB 295.6KiB
No change  IMG 140.74KiB 140.74KiB
No change  HTML 1.38KiB 1.38KiB
No change  Other 871B 871B

Bundle analysis reportBranch florian-h05:logviewer-limit-colu...Project dashboard


Generated by RelativeCIDocumentationReport issue

@florian-h05
Copy link
Contributor Author

/cc @cdjackson @ghys

@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI labels Jan 13, 2025
@florian-h05 florian-h05 changed the title Log viewer: Fixed column width for timestamp, level & logger Log viewer: Fixed column width for timestamp, level & logger name Jan 13, 2025
@cdjackson
Copy link
Contributor

Thanks - I'll take a look later today.

Just to mention I noticed a bug on the table / column widths a day or two ago. Due to the virtual table, the column widths change as you scroll up/down through the list - depending on what part of the log is displayed. This ought to fix this.

Just for info I'm working on core changes and UI changes to improve the log display. By sending logs in an array rather than single messages speeds things up a hell of a lot (I've not tried it with zigbee debug yet, but sending through 100 lines of historic logs is essentially instantaneous rather than taking maybe a few hundred ms).

@florian-h05
Copy link
Contributor Author

Just for info I'm working on core changes and UI changes to improve the log display. By sending logs in an array rather than single messages speeds things up a hell of a lot

Great to hear that and thanks for letting me know 👍

@cdjackson
Copy link
Contributor

I'm reasonably ok with this. I do find the truncation of the logger slightly annoying, but on balance it's fine.

The time column seems to change width - depending on the message. ie if the message is long, then the time column is shrunk...

image image

@florian-h05
Copy link
Contributor Author

The time column seems to change width - depending on the message. ie if the message is long, then the time column is shrunk...

That’s because this PR was developed on top of your logger icon PR, the icon will avoid that behaviour.

@mherwege
Copy link
Contributor

Instead of actually cutting the logger name, can't you do something with styling like suggested here: https://stackoverflow.com/questions/47926246/how-can-i-align-text-to-the-right-in-a-div-so-its-beginning-is-cut-down-with-ove ?

Cutting the text on the number of characters is difficult when not using a fixed width character set.

@florian-h05
Copy link
Contributor Author

Setting width, and text-align right together with overflow hidden doesn't work.

@florian-h05
Copy link
Contributor Author

I will merge this soon, we can always come back and improve later if we find a better solution, but for now this already is an improvement.

@mherwege
Copy link
Contributor

mherwege commented Jan 15, 2025

This style does align right and cut, but I can't get ellipsis to work:

  td.logger
    width 280px
    overflow hidden
    text-align right
    display flex
    justify-content flex-end
    align-items center
    height 29px

@mherwege
Copy link
Contributor

mherwege commented Jan 15, 2025

I think I solved it:

instead of a td.logger style, replace it with:

  span.logger
    width 280px
    display block
    direction rtl
    overflow hidden
    text-overflow ellipsis

and use this for the HTML:

      tr.innerHTML = '<td class="sticky"><i class="icon f7-icons" style="font-size: 18px;">' + icon + `</i> ${entity.time}<span class="milliseconds">${entity.milliseconds}</span></td>` +
        `<td>${entity.level}</td>` +
        `<td><span class="logger">${entity.loggerName}</span></td>` +
        `<td class="nowrap">${this.highlightText(entity.message)}</td>`

Signed-off-by: Florian Hotze <dev@florianhotze.com>
@florian-h05 florian-h05 force-pushed the logviewer-limit-column-width branch from b239fbb to f8c86bb Compare January 15, 2025 17:43
@florian-h05
Copy link
Contributor Author

Thanks for the help @mherwege, got it working now with some extra styling.

@florian-h05
Copy link
Contributor Author

Bildschirmaufnahme_20250115_184520.webm

@florian-h05 florian-h05 added this to the 5.0 milestone Jan 15, 2025
@florian-h05 florian-h05 merged commit 9885f09 into openhab:main Jan 15, 2025
5 checks passed
@florian-h05 florian-h05 deleted the logviewer-limit-column-width branch January 15, 2025 17:48
width 50px

td.logger
width 280px
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn’t need this when testing in Firefox. It will not harm either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed this when developing in Chromium.

Copy link
Contributor

Choose a reason for hiding this comment

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

For some strange reason, when I was trying this, things worked in Firefox, but I couldn’t even get the websocket connection to start in Chrome, so no way to test (there was an error in the console). That is obviously another issue and I will keep an eye out for it.

florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Jan 16, 2025
Signed-off-by: Florian Hotze <dev@florianhotze.com>
@cdjackson
Copy link
Contributor

In my opinion, the logger name now looks strange. The right alignment makes it difficult to read - it's ok if they are all truncated, but it's strange if some fit and some don't.

image

For me, it should be left aligned, with the left side truncated if it's too long. I think this is what the original PR here did...

florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Jan 17, 2025
Refs openhab#3011.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
@florian-h05
Copy link
Contributor Author

For me, it should be left aligned, with the left side truncated if it's too long.

I agree, will change that: #3026

florian-h05 added a commit that referenced this pull request Jan 17, 2025
Refs #3011.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
@cdjackson
Copy link
Contributor

Thanks @florian-h05 I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants