这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@J-N-K
Copy link
Member

@J-N-K J-N-K commented Nov 1, 2023

This adds a web socket connection for receiving logs. Similar to #3345 but for web sockets instead of SSE.

@ghys FYI. It works fine with the LogReaderServiceand the LogListener.

This adds a websocket connection for receiving logs.

Signed-off-by: Jan N. Klug <github@klug.nrw>
@J-N-K J-N-K added the enhancement An enhancement or new feature of the Core label Nov 1, 2023
@J-N-K J-N-K requested a review from a team as a code owner November 1, 2023 10:06
@spacemanspiff2007
Copy link
Contributor

Would it be also possible to add a short example to the docs how to use this?

@J-N-K
Copy link
Member Author

J-N-K commented Nov 1, 2023

Sure. Short description: open a web socket connection to /ws/logs and receive all logs. Sending an array of regex will enable a filter: only lines where the logging bundle matches at least one regex will be sent over the connection (e.g. ["org\.openhab\.core\..*"] would only allow core messages to pass). An empty array again enables "full logging".

@spacemanspiff2007
Copy link
Contributor

Perfect. The regex matches the whole line? So that's what I would want to use to filter e.g. for the levels INFO, WARNING and ERROR. Or is there an option to set the log level?

@J-N-K J-N-K mentioned this pull request Nov 4, 2023
@spacemanspiff2007
Copy link
Contributor

Just to clarify - I am looking for a way to subscribe to all messages of level INFO and above (e.g. WARNING, ERROR, CRITICAL and whatever other levels there may be).

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

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

Thanks!

@kaikreuzer kaikreuzer merged commit 8a6e743 into openhab:main Nov 22, 2023
@kaikreuzer kaikreuzer added this to the 4.1 milestone Nov 22, 2023
@spacemanspiff2007
Copy link
Contributor

What if I want to filter by log level and not by regex.
How can I set the filter to get everything of log level including INFO and above?
Or is there an overview of the availalbe log levels? I'm guessing the log levels can be added dynamically - are there levels which are specific to openHAB?

@spacemanspiff2007
Copy link
Contributor

@J-N-K :
Is it possible to filter by log level? E.g. if I want only messages with level INFO and above?

@J-N-K J-N-K deleted the feature-log-websocket branch December 10, 2023 17:25
@J-N-K
Copy link
Member Author

J-N-K commented Dec 10, 2023

No, this passes on what goes to the logger. I also think it would be confusing, because if you add TRACE but no logger is configured for TRACE logging, you would not get any other information.

@spacemanspiff2007
Copy link
Contributor

No, this passes on what goes to the logger. I also think it would be confusing, because if you add TRACE but no logger is configured for TRACE logging, you would not get any other information.

You misunderstand. If I configure TRACE I'd expect to get TRACE and above, e.g. all messages withTRACE, DEBUG, INFO, WARNING and ERROR.
If I configure INFO I'd expect to get INFO, WARNING and ERROR.

Or do you have another idea how I can get all WARNING and ERROR messages without client side filtering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature of the Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants