diff options
Diffstat (limited to 'plugin.video.embycon/resources/lib/simple_logging.py')
-rw-r--r-- | plugin.video.embycon/resources/lib/simple_logging.py | 39 |
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) |