summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal/Plugin.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-14 17:43:31 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-14 17:43:31 +0200
commitea27af7361bb75d665c29120d9cdc254a209afa8 (patch)
treed45867d45c4022e5739935948819272608793e47 /module/plugins/internal/Plugin.py
parentMerge branch 'pr/n1485_EvolutionClip' into stable (diff)
downloadpyload-ea27af7361bb75d665c29120d9cdc254a209afa8.tar.xz
Move new log functions to Plugin
Diffstat (limited to 'module/plugins/internal/Plugin.py')
-rw-r--r--module/plugins/internal/Plugin.py35
1 files changed, 26 insertions, 9 deletions
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index 228685ee5..aef8fd450 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -31,8 +31,8 @@ if os.name != "nt":
from itertools import islice
-from module.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload
-from module.utils import save_join, save_path, fs_encode, fs_decode
+from module.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload #@TODO: Remove in 0.4.10
+from module.utils import decode, save_join, save_path, fs_encode, fs_decode
def chunks(iterable, size):
it = iter(iterable)
@@ -55,18 +55,35 @@ class Base(object):
#: core config
self.config = core.config
- #log functions
+ # Log functions
+ def _log(self, level, args):
+ log = getattr(self.core.log, level)
+ msg = " | ".join((fs_encode(a) if isinstance(a, unicode) else #@NOTE: `fs_encode` -> `encode` in 0.4.10
+ str(a)).strip() for a in args if a)
+ log("%(plugin)s[%(id)s]: %(msg)s" % {'plugin': self.__name__,
+ 'id' : self.pyfile.id,
+ 'msg' : msg or _(level.upper() + " MARK")})
+
+
+ def logDebug(self, *args):
+ if self.core.debug:
+ return self._log("debug", args)
+
+
def logInfo(self, *args):
- self.log.info("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args])))
+ return self._log("info", args)
+
def logWarning(self, *args):
- self.log.warning("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args])))
+ return self._log("warning", args)
+
def logError(self, *args):
- self.log.error("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args])))
+ return self._log("error", args)
- def logDebug(self, *args):
- self.log.debug("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args])))
+
+ def logCritical(self, *args):
+ return self._log("critical", args)
def setConf(self, option, value):
@@ -123,7 +140,7 @@ class Plugin(Base):
Overwrite `process` / `decrypt` in your subclassed plugin.
"""
__name__ = "Plugin"
- __version__ = "0.05"
+ __version__ = "0.06"
__pattern__ = None
__type__ = "hoster"
__config__ = [("name", "type", "desc", "default")]