summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal/Plugin.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-07 20:26:03 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-07 20:26:03 +0200
commit306e76eb283f158e9cd415bd2ece49a3c0289c9a (patch)
tree0cfa7e1d6682929e510c6b50d840f14cc8fbe4de /module/plugins/internal/Plugin.py
parentMerge pull request #1964 from kasperj/stable (diff)
parent[log_xxx()] introduce 'traceback' argument (diff)
downloadpyload-306e76eb283f158e9cd415bd2ece49a3c0289c9a.tar.xz
Merge pull request #1957 from GammaC0de/patch-3
[Plugin] introduce 'traceback' argument in log_xxx() functions
Diffstat (limited to 'module/plugins/internal/Plugin.py')
-rw-r--r--module/plugins/internal/Plugin.py96
1 files changed, 80 insertions, 16 deletions
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index d89c3d2c0..bd5251e2e 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -226,7 +226,7 @@ def chunks(iterable, size):
class Plugin(object):
__name__ = "Plugin"
__type__ = "plugin"
- __version__ = "0.48"
+ __version__ = "0.49"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -270,30 +270,94 @@ class Plugin(object):
'msg' : msg})
- def log_debug(self, *args):
- if not self.pyload.debug:
- return
- self._log("debug", self.__type__, self.__name__, args)
+ def log_debug(self, *args, **kwargs):
+ frame = inspect.currentframe()
+ try:
+ if kwargs:
+ for key, val in kwargs.iteritems():
+ if key not in ("traceback"):
+ raise TypeError(frame.f_code.co_name + "() got an unexpected keyword argument '" + key + "'")
+ if not self.pyload.debug:
+ return
- def log_info(self, *args):
- self._log("info", self.__type__, self.__name__, args)
+ self._log("debug", self.__type__, self.__name__, args)
+ if kwargs.get('traceback') is True:
+ traceback.print_stack(frame.f_back)
- def log_warning(self, *args):
- self._log("warning", self.__type__, self.__name__, args)
+ finally:
+ del frame
- def log_error(self, *args):
- self._log("error", self.__type__, self.__name__, args)
- if self.pyload.debug:
- traceback.print_exc()
+ def log_info(self, *args, **kwargs):
+ frame = inspect.currentframe()
+ try:
+ if kwargs:
+ for key, val in kwargs.iteritems():
+ if key not in ("traceback"):
+ raise TypeError(frame.f_code.co_name + "() got an unexpected keyword argument '" + key + "'")
+
+ self._log("info", self.__type__, self.__name__, args)
+
+ if kwargs.get('traceback') is True:
+ traceback.print_stack(frame.f_back)
+
+ finally:
+ del frame
+
+
+ def log_warning(self, *args, **kwargs):
+ frame = inspect.currentframe()
+ try:
+ if kwargs:
+ for key, val in kwargs.iteritems():
+ if key not in ("traceback"):
+ raise TypeError(frame.f_code.co_name + "() got an unexpected keyword argument '" + key + "'")
+
+ self._log("warning", self.__type__, self.__name__, args)
+
+ if kwargs.get('traceback') is True:
+ traceback.print_stack(frame.f_back)
+
+ finally:
+ del frame
+
+
+ def log_error(self, *args, **kwargs):
+ frame = inspect.currentframe()
+ try:
+ if kwargs:
+ for key, val in kwargs.iteritems():
+ if key not in ("traceback"):
+ raise TypeError(frame.f_code.co_name + "() got an unexpected keyword argument '" + key + "'")
+
+ self._log("error", self.__type__, self.__name__, args)
+
+ if kwargs.get('traceback') is True:
+ traceback.print_stack(frame.f_back)
+
+ finally:
+ del frame
def log_critical(self, *args):
- return self._log("critical", self.__type__, self.__name__, args)
- if self.pyload.debug:
- traceback.print_exc()
+ frame = inspect.currentframe()
+ try:
+ if kwargs:
+ for key, val in kwargs.iteritems():
+ if key not in ("traceback"):
+ raise TypeError(frame.f_code.co_name + "() got an unexpected keyword argument '" + key + "'")
+
+ self._log("critical", self.__type__, self.__name__, args)
+
+ if kwargs.get('traceback') is False:
+ return
+ if self.pyload.debug:
+ traceback.print_stack(frame.f_back)
+
+ finally:
+ del frame
def set_permissions(self, path):