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

Allow changing add-on log-levels #1351

Closed
J-N-K opened this issue Apr 10, 2022 · 7 comments · Fixed by #1452
Closed

Allow changing add-on log-levels #1351

J-N-K opened this issue Apr 10, 2022 · 7 comments · Fixed by #1452
Labels
enhancement New feature or request main ui Main UI

Comments

@J-N-K
Copy link
Member

J-N-K commented Apr 10, 2022

The problem

Add-on logger levels can't be changed from the UI. See #1376. Core support was added in openhab/openhab-core#2772.

Your suggestion

Bildschirmfoto 2022-04-10 um 13 30 56

Additional information

This was done by changing addon-details.vue

              <div class="addon-header-actions">
                <f7-preloader v-if="isPending(addon)" color="blue" />
                <f7-button v-else-if="addon.installed" class="install-button" text="Remove" color="red" round small fill @click="openAddonPopup" />
                <f7-button v-else class="install-button" :text="installableAddon(addon) ? 'Install' : 'Add'" color="blue" round small fill @click="openAddonPopup" />
                <f7-link v-if="!isPending(addon) && bindingInfo && bindingInfo.configDescriptionURI" icon-f7="gears" tooltip="Configure Binding" color="blue" :href="'/settings/addons/' + bindingInfo.id + '/config'" round small />
                <select v-if="addon.installed" class="button button-round button-fill color-lime">
                  <option value="TRACE">
                    Log: TRACE
                  </option>
                  <option value="DEBUG">
                    Log: DEBUG
                  </option>
                  <option value="INFO">
                    Log: INFO
                  </option>
                  <option value="WARN">
                    Log: WARN
                  </option>
                  <option value="ERROR">
                    Log: ERROR
                  </option>
                </select>
              </div>

I'm pretty sure this is not the correct way to do it, but I have no idea what is the correct way. Also functionality is missing, that's why I didn't make a PR.

@J-N-K J-N-K added enhancement New feature or request main ui Main UI labels Apr 10, 2022
@ghys
Copy link
Member

ghys commented Apr 13, 2022

I would rather (re) use the dedicated page to configure bindings and generalize it to all add-ons.
On that page you would then have both the log level configuration and the eventual binding parameters, if any.
It would also be nice to have a SSE/websocket endpoint to stream the related logs (if at all possible), which could be shown on this page as well.

@mherwege
Copy link
Contributor

mherwege commented May 25, 2022

@ghys @J-N-K I tried having a go at this to make it work in the configuration pages of an add-on. While I can make it work for bindings that come with the distribution, anything else is a problem.

  • Marketplace bindings don't have loggerPackages included in their addon rest reply
  • Configurations from the add-on page can only be retrieved for bindings provided by the distribution (karaf), as the bindingId cannot be derived from the addonId, therefore the binding rest call to find the configurationURI is not possible
  • Other add-on types than bindings need even more logic to try to figure out the serviceId to be able to query the services endpoint for the configurationURI

I believe #2058 has a promise to solve this, by bringing it all together in the addon endpoint. This would greatly simplify things.

Ideally, I would also like to have the option to switch log levels on installed rule templates in the same way. For this to work, the logger name should also be provided in the rule template.

@J-N-K
Copy link
Member Author

J-N-K commented May 25, 2022

openhab/openhab-core#2058 is very high on my list of issues to work on, though probably not before 3.3 as this will probably result in a breaking change and I would prefer not to merge something fundamental like this before the release.

You are correct, there is currently no solution for community marketplace bindings. This is easy to solve in the marketplace code once a solution has been found how to add that to the Discourse posts. The JSON 3rd party add-on service already supports providing the package names (if presented by the service).

Configurations can be done on the add-on page or on the "Add a thing" page. This should also work for marketplace add-ons. The JSON 3rd party add-on service already provides the URI (if presented by the service).

@J-N-K
Copy link
Member Author

J-N-K commented May 25, 2022

If I correctly understand what @ghys proposes is to always show the gear (even on add-ons that don't have any configuration) and then add the log-setting to that page (similar to an always present configuration parameter). It would be nice if it could be set individually for each package.

@mherwege
Copy link
Contributor

@J-N-K That’s indeed also what I was trying to achieve.

I am aware you can configure marketplace bindings from the add a thing page.

Don’t just focus on bindings. There are other types of add-ons, and the logger level and configuration should ideally be done in the same way. The addons Rest end-point could work for all of them, but looking at the underlying code, it will probably indeed require braking changes.

@J-N-K
Copy link
Member Author

J-N-K commented May 26, 2022

It should work out-of-the-box for all distribution add-ons, no matter what type they are:

{
    "id": "voice-porcupineks",
    "label": "Porcupine Keyword Spotter",
    "version": "3.3.0.SNAPSHOT",
    "compatible": true,
    "contentType": "application/vnd.openhab.feature;type=karaf",
    "link": "https://www.openhab.org/addons/voice/porcupineks/",
    "author": "openHAB",
    "verifiedAuthor": true,
    "installed": false,
    "type": "voice",
    "configDescriptionURI": "",
    "keywords": "",
    "countries": "",
    "connection": "",
    "properties": {},
    "loggerPackages": [
      "org.openhab.voice.porcupineks"
    ]
  },

@mhilbush
Copy link
Contributor

mhilbush commented Feb 5, 2023

@J-N-K @ghys I'm a bit confused by this. In recent snapshots (3299 in my case), I'm no longer seeing the binding config. All I see is the option to set the log level. It was working in 3292.

https://community.openhab.org/t/binding-configuration-missing-in-recent-4-0-0-builds/144118

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 a pull request may close this issue.

4 participants