From a0c96c634d14f3d40bf4b06d8a6f23dd431c91b8 Mon Sep 17 00:00:00 2001 From: ael-code Date: Fri, 11 Nov 2016 11:35:28 +0100 Subject: Expose logging facilities to commands All the subclass of the Command class can now use the the class object `Command.log` for logging pourposes. This is a standard `logging.Logger` instance, thus the standard logging api must be used. Example: ``` class dummy_cmd(Command): def execute(self): self.log.info("the dummy command has been invoked") ``` --- ranger/api/commands.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ranger/api/commands.py') diff --git a/ranger/api/commands.py b/ranger/api/commands.py index 9b8ec7d5..93c50adb 100644 --- a/ranger/api/commands.py +++ b/ranger/api/commands.py @@ -236,6 +236,11 @@ class Command(FileManagerAware): break return flags, rest + @lazy_property + def log(self): + import logging + return logging.getLogger('ranger.commands.' + self.__class__.__name__) + # XXX: Lazy properties? Not so smart? self.line can change after all! @lazy_property def _tabinsert_left(self): -- cgit 1.4.1-2-gfad0