Skip to content

Commit

Permalink
Merge pull request #213 from MoojMidge/matrix-logging
Browse files Browse the repository at this point in the history
Update logging function to address #205
  • Loading branch information
im85288 authored Sep 17, 2020
2 parents a40b72b + f7aee6e commit a7a6cb6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions resources/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from __future__ import absolute_import, division, unicode_literals
import sys
import json
from xbmc import executeJSONRPC, getRegion, log as xlog, LOGDEBUG, LOGNOTICE
from xbmc import (
executeJSONRPC, getInfoLabel, getRegion, log as xlog, LOGDEBUG, LOGINFO
)
from xbmcaddon import Addon
from xbmcgui import Window
from statichelper import from_unicode, to_unicode
Expand All @@ -27,6 +29,12 @@ def addon_path():
return get_addon_info('path')


def get_kodi_version():
"""Return Kodi version number as float"""
build = getInfoLabel("System.BuildVersion")
return float(build[:4])


def get_property(key, window_id=10000):
"""Get a Window property"""
return to_unicode(Window(window_id).getProperty(key))
Expand Down Expand Up @@ -143,7 +151,12 @@ def log(msg, name=None, level=1):
set_property('logLevel', log_level)
if not debug_logging and log_level < level:
return
level = LOGDEBUG if debug_logging else LOGNOTICE
if debug_logging:
level = LOGDEBUG
elif get_kodi_version() >= 19:
level = LOGINFO
else:
level = LOGINFO + 1
xlog('[%s] %s -> %s' % (addon_id(), name, from_unicode(msg)), level=level)


Expand Down

0 comments on commit a7a6cb6

Please sign in to comment.