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

[addons] Less debug log entries when accessing settings #17822

Merged
merged 1 commit into from
Aug 27, 2020
Merged

[addons] Less debug log entries when accessing settings #17822

merged 1 commit into from
Aug 27, 2020

Conversation

matthuisman
Copy link
Contributor

@matthuisman matthuisman commented May 8, 2020

Description

If there is a service add-on running a loop that accesses the addon settings, it can quickly fill up the debug log with essentially non-helpful messages.

"failed to find definition for setting {}. Creating a setting on-the-fly..."
This shows if the add-on has removed a setting but the user still has that setting in their userdata.
They can't do anything about that and neither can the author. So can we stop logging about it?

"CSettingsManager: requested setting ({}) was not found" is still logged when a setting isn't actually in the settings.xml but tried to access via the add-on.

"loading setting values"
Do we need to know this? - it logs if this fails anyway.

"loading setting definitions"
Same as above.

Yes, its only debug messages.
But users use debug log to find issues.
So the less "bloat" of unneeded messages - the easier to find their issue.

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@phunkyfish phunkyfish requested a review from Montellese May 8, 2020 08:54
@phunkyfish phunkyfish added v19 Matrix Component: Settings Component: Logging Type: Cleanup non-breaking change which removes non-working or unmaintained functionality labels May 8, 2020
Copy link
Member

@garbear garbear left a comment

Choose a reason for hiding this comment

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

If log spam is identified in a loop, then removing it makes usually sense.

@matthuisman
Copy link
Contributor Author

Back port to Leia possible?
I can PR for that?

@@ -683,8 +676,6 @@ std::shared_ptr<CSettingCategory> CAddonSettings::ParseOldCategoryElement(uint32

bool CAddonSettings::InitializeFromOldSettingDefinitions(const CXBMCTinyXML& doc)
{
m_logger->debug("trying to load setting definitions from old format...");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe keep this one and encourage add-on developers to migrate to the new settings format? If we remove this on v20 we should probably advise in v19

Copy link
Contributor Author

@matthuisman matthuisman May 8, 2020

Choose a reason for hiding this comment

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

Is there anywhere the warning could go that only shows once per addon call? Currently it shows every time a setting is read.

I think still best to remove. As having it puts it in all users logs (not just devs). An addon dev should be familiar with changes and be reading the forum posts in regards to depreciations etc. Eg. There is no warning in 18 about python2 being depreciated in 19? But most addon devs I'm sure are quite aware by now

Copy link
Member

Choose a reason for hiding this comment

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

It should only show when loading the settings for an add-on. It shouldn't show on every access to the setting from the same script. Otherwise something else is wrong. But I agree that it is logged out too often especially for non-service add-ons. But for debugging setting issues it's still important information to know that Kodi tries to load old style settings.

So if we can find a way to show it once for every add-on with settings that's ok with me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ill double check when it's getting logged.

Could leave in 19 and remove from 18 (if back port)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe keep this one and encourage add-on developers to migrate to the new settings format?

are there any guidelines?
the last time i made a conversion (last year) attempt i noticed a lack of ability to run "actions" with python add-on

Copy link
Contributor

Choose a reason for hiding this comment

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

I see this logged all the time and my addons use the new setting format. Does it default to checking the old format first?

Copy link
Member

Choose a reason for hiding this comment

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

For add-ons using the old settings style logging should look like this:

loading setting definitions
trying to load setting definitions from old format...

For add-ons using the new settings style logging should look like this:

loading setting definitions

Copy link
Contributor

Choose a reason for hiding this comment

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

Apologies, you are correct. I had mixed up Leia (old settings) vs Matrix (new settings).

@@ -684,7 +677,7 @@ std::shared_ptr<CSettingCategory> CAddonSettings::ParseOldCategoryElement(uint32
bool CAddonSettings::InitializeFromOldSettingDefinitions(const CXBMCTinyXML& doc)
{
m_logger->debug("trying to load setting definitions from old format...");

Copy link
Member

Choose a reason for hiding this comment

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

Please remove the white space at the end of the line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, my editor adds that on new lines.
Removed now

Copy link
Contributor

Choose a reason for hiding this comment

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

@matthuisman any chance you want to quickly fix this up so we can get it merged when you have some time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whitespace? It is already fixed :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fuzzard oops - your right - now should be fixed 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

cheers mate. ill merge it when jenkins finishes

@KarellenX
Copy link
Member

KarellenX commented May 10, 2020

Thanks @matthuisman I have raised this log spam issue a number of times previously. Will make the logs easier to read and smaller for the paste sites.

@matthuisman
Copy link
Contributor Author

matthuisman commented May 10, 2020

another thing I need to look into

$ADDON[addon_id 32035] doesn't work for lvalues in settings.xml
Maybe does in new settings though?

I reuse a lot of settings / language strings from a common add-on.
Nice not having to duplicate language strings between them.

Trying to keep a single add-on code working over all kodi versions is getting tricky.
I think the settings.xml changes will break that :(

Be nice if we could ship a settings.old.xml or something to keep backwards compatible :)

Copy link
Contributor

@phunkyfish phunkyfish left a comment

Choose a reason for hiding this comment

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

@matthuisman I think the statement you are removing is primarily printed when you have a setting in your settings.xml which is not used by the addon. The logging is verbose if you have extra unused settings. But then maybe it should be.

I only see the settings loaded one time in the log in matrix.

@matthuisman
Copy link
Contributor Author

it shows if you had a setting in the userdata settings.xml but not in the addons setting.xml
eg. an old setting that has been removed by the add-on author.

You can test by just adding a setting in settings.xml
Go into add-on and set it.
Then remove that setting from the settings.xml

we should be able to remove old settings and not spam the log?
If the setting is no longer in the addons setting.xml - it should be removed from the userdata?

@phunkyfish
Copy link
Contributor

I thinks that’s reasonable. And maybe create a backup and then remove the older settings. At least the user still has access to the data then.

@matthuisman
Copy link
Contributor Author

matthuisman commented May 10, 2020

addons shouldn't be manually editing the userdata settings.xml and having to parse xml to remove old settings?

Its fine if that old setting sits there - but it shouldn't start spamming the log.
There is nothing the user / developer can do about it - so why warn about it?

If a setting is in userdata settings.xml and not in add-on settings.xml - then it should just ignore it.

For the user to get rid of that message, they need to manually open the userdata settings.xml and remove the entry for that old setting. Thats not very friendly?

I think the main problem is the verobosity of the logging.
Debug logging in Kodi should probably be actually a higher up level

If the addon tries to get a setting that doesn't exist anymore, we still get the
"CSettingsManager: requested setting ({}) was not found" log message - which is fine.

@Montellese
Copy link
Member

another thing I need to look into

$ADDON[addon_id 32035] doesn't work for lvalues in settings.xml
Maybe does in new settings though?

I don't think that will work since I didn't even know it was possible.

@Montellese
Copy link
Member

it shows if you had a setting in the userdata settings.xml but not in the addons setting.xml
eg. an old setting that has been removed by the add-on author.

You can test by just adding a setting in settings.xml
Go into add-on and set it.
Then remove that setting from the settings.xml

we should be able to remove old settings and not spam the log?
If the setting is no longer in the addons setting.xml - it should be removed from the userdata?

IIRC the reason I added this log message in the first place was because someone pointed out that with the old settings it must be possible to create settings which don't exist in the add-on's settings.xml. Back then I didn't think that this was a good idea (what do we have settings.xml for then?) so I added this log. But it seems like this also happens when removing a previously existing setting from settings.xml which is a perfectly valid use case.

@matthuisman
Copy link
Contributor Author

I don't think that will work since I didn't even know it was possible.

Yeh, I only found you could do it for most of the labels the other day.
Was pretty happy with that (I hate duplication)
Especially with language strings - as they can have translations.
So nice to reuse the common strings if possible.
Be nice if it worked everywhere though.
Surely we could pipe the lvalues through the same code that the label goes through to get the same behaviour. I can take a look :)

You still get the "CSettingsManager: requested setting ({}) was not found" if you try to access a setting that isn't in the settings.xml. Thats fine. That tells the dev - oh, I better add in the setting

@fuzzard
Copy link
Contributor

fuzzard commented Aug 27, 2020

@Montellese You ok with this to merge in its current state?

Copy link
Contributor

@fuzzard fuzzard left a comment

Choose a reason for hiding this comment

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

Doesn't show as fixed, did you push it?

@fuzzard fuzzard added this to the Matrix 19.0-alpha 2 milestone Aug 27, 2020
@phunkyfish
Copy link
Contributor

jenkins build this please

@fuzzard fuzzard merged commit bc01e01 into xbmc:master Aug 27, 2020
@matthuisman matthuisman deleted the quiet_addon_settings branch September 3, 2020 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Logging Component: Settings Type: Cleanup non-breaking change which removes non-working or unmaintained functionality v19 Matrix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants