How to get xbmc debug setting?
#1
I'm trying to determine within an addon whether the xbmc debug logging is enabled

From guisettings.xml the setting appears to be showloginfo:

Code:
<debug>
        <extralogging default="true">false</extralogging>
        <screenshotpath default="true"></screenshotpath>
        <setextraloglevel default="true"></setextraloglevel>
        <showloginfo>true</showloginfo>
    </debug>

So I would assume that this code should work and return a 1 when enabled:

Code:
xbmc.getCondVisibility('System.Setting(showloginfo)')

Though so far I haven't had any luck, always returns 0

Is this the correct setting value I should be checking? Syntax is correct?

Here's some json that works:

Code:
json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Settings.getSettings", "params": { "filter":{"section":"system", "category":"debug"} } }')
    json_query = unicode(json_query, 'utf-8', errors='ignore')
    json_response = json.loads(json_query)
    
    if 'result' in json_response and 'settings' in json_response['result'] and json_response['result']['settings'] is not None:
        for item in json_response['result']['settings']:
            if item["id"] == "debug.showloginfo":
                if item["value"] == True:
                    print 'debug is on'
                else:
                    print 'debug is off'
                break
Reply
#2
I wonder why you want to know if Kodi is in debug mode?
Python has the xbmc.loglevel for that with the different levels. If you really want to you could detect from there but still.
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#3
There is a piece of code that I would like to run and then output it's results to the log file, the code is a bit expensive to consistently run when not necessary

So preference would be to run it and print the log lines only when in debug mode
Reply
#4
Is that helpful? https://github.com/XBMC-Addons/script.ar...ils.py#L73
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#5
Thanks but don't think it does, xbmc.LOGDEBUG just returns a static number (0), doesn't tell me if the user has debugging enabled

That addon seems to have it's own debug mode?

https://github.com/XBMC-Addons/script.ar...s.xml#L100
Reply
#6
Is there a way to do this yet?
Reply
#7
For future reference, this is how I did it:

Code:
def debug():
    """Use Kodi's JSON-RPC API to determine whether debug logging is activated."""
    rpc_cmd = {
        'jsonrpc': '2.0',
        'method': 'Settings.GetSettingValue',
        'params': {'setting': 'debug.showloginfo'},
        'id': '1'
    }
    json_data = json.loads(xbmc.executeJSONRPC(json.dumps(rpc_cmd)))
    return json_data['result']['value']
Reply

Logout Mark Read Team Forum Stats Members Help
How to get xbmc debug setting?0