summaryrefslogtreecommitdiff
path: root/python/skytools/scripting.py
diff options
context:
space:
mode:
authormartinko2011-11-28 17:09:30 +0000
committermartinko2011-11-28 17:09:30 +0000
commit42bc4ea7840ec07951924de14c1cfc820bc83cb1 (patch)
tree5d05324e3278349312f4ecedac337d7783675d92 /python/skytools/scripting.py
parent767e4af07726f559edae35c272d6945bddba79e8 (diff)
skytools/scripting.py: added new log level TRACE that is below DEBUG level
Added new "debug-2" log level that is intended for finer-grained informational events than DEBUG log level.
Diffstat (limited to 'python/skytools/scripting.py')
-rw-r--r--python/skytools/scripting.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py
index cd79bf2d..8a24301b 100644
--- a/python/skytools/scripting.py
+++ b/python/skytools/scripting.py
@@ -118,6 +118,16 @@ def run_single_process(runnable, daemon, pidfile):
# logging setup
#
+logging.TRACE = TRACE = 5
+
+class SkyLogger (logging.getLoggerClass()):
+ def trace (self, msg, *args, **kwargs):
+ return self.log (TRACE, msg, *args, **kwargs)
+
+# start using our class when instantiating a logger
+logging.addLevelName (TRACE, 'TRACE')
+logging.setLoggerClass (SkyLogger)
+
_log_config_done = 0
_log_init_done = {}
@@ -297,7 +307,9 @@ class BaseScript(object):
self.go_daemon = 1
if self.options.quiet:
self.log_level = logging.WARNING
- if self.options.verbose:
+ if self.options.verbose > 1:
+ self.log_level = logging.TRACE
+ elif self.options.verbose:
self.log_level = logging.DEBUG
if self.options.ini:
self.print_ini()
@@ -393,7 +405,7 @@ class BaseScript(object):
# generic options
p.add_option("-q", "--quiet", action="store_true",
help = "log only errors and warnings")
- p.add_option("-v", "--verbose", action="store_true",
+ p.add_option("-v", "--verbose", action="count",
help = "log verbosely")
p.add_option("-d", "--daemon", action="store_true",
help = "go background")