summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorael-code <tommy.ael@gmail.com>2016-11-11 11:35:28 +0100
committerael-code <tommy.ael@gmail.com>2016-11-25 17:37:28 +0100
commita0c96c634d14f3d40bf4b06d8a6f23dd431c91b8 (patch)
treec1354f17193aec7f24e82d5d9ca472914a710cfd /ranger
parent3b7a9b18507261b7e734ec4d8180b71e199e3b21 (diff)
downloadranger-a0c96c634d14f3d40bf4b06d8a6f23dd431c91b8.tar.gz
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")
```
Diffstat (limited to 'ranger')
-rw-r--r--ranger/api/commands.py5
1 files changed, 5 insertions, 0 deletions
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):