summaryrefslogtreecommitdiff
path: root/plugin.video.embycon/resources/lib/simple_logging.py
diff options
context:
space:
mode:
authorshaun <shaun@bluebit.com.au>2018-01-25 08:19:32 +1100
committerMartijn Kaijser <martijn@xbmc.org>2018-01-31 20:19:15 +0100
commit091ca6e9975d8325e2fb46610e2761391f9a3998 (patch)
tree24102c5f0a2c83cccfa2db8b0fd8a37e6a3ee563 /plugin.video.embycon/resources/lib/simple_logging.py
parentdf562079c5d2ca5f0c5db8b66cbb78c5d8527e30 (diff)
[plugin.video.embycon] 1.4.39
Diffstat (limited to 'plugin.video.embycon/resources/lib/simple_logging.py')
-rw-r--r--plugin.video.embycon/resources/lib/simple_logging.py39
1 files changed, 23 insertions, 16 deletions
diff --git a/plugin.video.embycon/resources/lib/simple_logging.py b/plugin.video.embycon/resources/lib/simple_logging.py
index 63ce6ac..05230d9 100644
--- a/plugin.video.embycon/resources/lib/simple_logging.py
+++ b/plugin.video.embycon/resources/lib/simple_logging.py
@@ -19,23 +19,30 @@ class SimpleLogging():
current_value = setting_result.get("result", None)
if current_value is not None:
self.enable_logging = current_value.get("value", False)
- #xbmc.log("LOGGING_ENABLED %s: %s" % (self.name, str(self.enable_logging)), level=xbmc.LOGDEBUG)
+ xbmc.log("LOGGING_ENABLED %s : %s" % (self.name, str(self.enable_logging)), level=xbmc.LOGDEBUG)
def __str__(self):
return "LoggingEnabled: " + str(self.enable_logging)
- def error(self, msg):
- try:
- xbmc.log(self.format(msg, "ERROR"), level=xbmc.LOGERROR)
- except UnicodeEncodeError:
- xbmc.log(self.format(msg, "ERROR").encode('utf-8'), level=xbmc.LOGERROR)
-
- def debug(self, msg):
- if (self.enable_logging):
- try:
- xbmc.log(self.format(msg, "DEBUG"), level=xbmc.LOGDEBUG)
- except UnicodeEncodeError:
- xbmc.log(self.format(msg, "DEBUG").encode('utf-8'), level=xbmc.LOGDEBUG)
-
- def format(self, msg, levelValue):
- return self.name + "(" + str(levelValue) + ") -> " + msg
+ def error(self, fmt, *args, **kwargs):
+ new_args = []
+ # convert any unicode to utf-8 strings
+ for arg in args:
+ if isinstance(arg, unicode):
+ new_args.append(arg.encode("utf-8"))
+ else:
+ new_args.append(arg)
+ log_line = self.name + " (ERROR) -> " + fmt.format(*new_args)
+ xbmc.log(log_line, level=xbmc.LOGDEBUG)
+
+ def debug(self, fmt, *args, **kwargs):
+ if self.enable_logging:
+ new_args = []
+ # convert any unicode to utf-8 strings
+ for arg in args:
+ if isinstance(arg, unicode):
+ new_args.append(arg.encode("utf-8"))
+ else:
+ new_args.append(arg)
+ log_line = self.name + " (DEBUG) -> " + fmt.format(*new_args)
+ xbmc.log(log_line, level=xbmc.LOGDEBUG)