openhab / openhab-webui

Web UIs of openHAB
Eclipse Public License 2.0
224 stars 242 forks source link

Add log viewer directly to the main UI #2883

Open cdjackson opened 5 days ago

cdjackson commented 5 days ago

Currently frontail is available as an addon in openhabian. I just moved my main system to a new server that's not openhabian - Frontail requires a lot of dependencies so I wanted to avoid loading it - it also seems to be no longer developed, and it would be nice(r) IMHO to have a log viewer directly embedded within the Developer Tools menu in the main UI. I guess given there is a websocket /logs endpoint in the core, this was also considered as the way forward...

I just wanted to raise this issue for visibility / comment. Is anyone working on such a viewer? I've not found anything from a quick search other than these closed issues.

1185

1109

I very quickly hacked something together last week as an initial concept to display the logs and manipulate logging levels - it needs a LOT more work to make it what I'd personally like to see. If someone is already working on a viewer or has plans, or has a minimum product etc, then I won't spend too much time on it, but if not I might look to put together a minimum solution. Conversely, if someone does have something running, maybe they'd like to share...

image
ghys commented 4 days ago

@cdjackson I had planned to do this once with a SSE source:

https://github.com/openhab/openhab-core/pull/3345

but as I thought openHAB's future was to move from SSEs to WebSockets I abandoned the idea. Perhaps your solution uses https://github.com/openhab/openhab-core/pull/3859?

cdjackson commented 4 days ago

Thanks @ghys

Yes, I'm using the websocket interface you reference - it's working quite well in my testing.

Since it looks like there's nothing currently being worked on, I'll try and get a draft (and rough) PR out in the next week or so. Currently I'm fighting some CSS issues (I'dd forgotten how much I hate CSS!). I've got a few different ways to filter / highlight the logs to try and make them a bit easier to view (one of my main drivers).

I have a question that maybe you can point me in the right direction - currently I've hard coded a token to access websockets - is there some way that this can be done automatically? Can you point me at some code?

Thanks.

ghys commented 3 days ago

This is normally handled in https://github.com/openhab/openhab-webui/blob/main/bundles/org.openhab.ui/web/src/components/auth-mixin.js and https://github.com/openhab/openhab-webui/blob/main/bundles/org.openhab.ui/web/src/js/openhab/auth.js.

You're not supposed to have a way to get the current access_token which is refreshed regularly every hour or so before it expires - but instead use APIs and abstraction layers which will use it for you, refresh it when necessary, but not expose it. (but there's a trick where you can force a refresh and get a new one - I could expand but this is not the ideal way.)

Since there's no current WebSocket client implementation yet it's a blank state how to deal with the access token in a new WebSocket API...

As for the presentation this is definitely a developer tool so it belongs there, but we could also have it part of the "developer sidebar", eventually opening a bottom drawer (https://v5.framework7.io/docs/sheet-modal) so you can see the logs while working on other stuff.