diff --git a/bin/linspector b/bin/linspector
index 752b160..a62cb1d 100755
--- a/bin/linspector
+++ b/bin/linspector
@@ -161,7 +161,7 @@ def main():
print("\nScheduled " + str(job_count) + " jobs")
- interface = LinspectorInterface(jobs, scheduler, lin_conf)
+ interface = LinspectorInterface(jobs, scheduler, lin_conf, root_logger)
if "jsonrpc_backend" in core and core["jsonrpc_backend"]:
jsonrpc = JsonrpcBackend(interface, core)
diff --git a/linspector/core/interface.py b/linspector/core/interface.py
index 482e684..9cd1c50 100644
--- a/linspector/core/interface.py
+++ b/linspector/core/interface.py
@@ -20,17 +20,19 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
"""
-from collections import OrderedDict
-from logging import getLogger
+import logging
-logger = getLogger(__name__)
+from collections import OrderedDict
+
+logger = logging.getLogger(__name__)
class LinspectorInterface(object):
- def __init__(self, jobs, scheduler, linspectorConfig):
+ def __init__(self, jobs, scheduler, linspectorConfig, root_logger):
self.jobs = jobs
self._scheduler = scheduler
self._config = linspectorConfig
+ self._root_logger = root_logger
self._recompute_job_hex_strings()
def _recompute_job_hex_strings(self):
@@ -160,4 +162,15 @@ class LinspectorInterface(object):
def get_thread_count(self):
return {"Num Threads": str(self._scheduler._threadpool.num_threads),
- "Max Threads": str(self._scheduler._threadpool.max_threads)}
\ No newline at end of file
+ "Max Threads": str(self._scheduler._threadpool.max_threads)}
+
+ def set_log_level(self, log_level):
+ if log_level == "debug":
+ level = logging.DEBUG
+ elif log_level == "error":
+ level = logging.ERROR
+ elif log_level == "info":
+ level = logging.INFO
+ elif log_level == "warning":
+ level = logging.WARNING
+ self._root_logger.setLevel(level)
\ No newline at end of file
diff --git a/linspector/frontends/lish.py b/linspector/frontends/lish.py
index f9d6a98..609921f 100644
--- a/linspector/frontends/lish.py
+++ b/linspector/frontends/lish.py
@@ -350,7 +350,9 @@ Usage:
pass
def do_log(self, text):
- if text == "less":
+ text = shsplit(text)
+
+ if text[0] == "less":
try:
# TODO: do the less on the logfile set by args and not a static path
with open(os.path.dirname(os.path.abspath(__file__)) + "/../../log/linspector.log"):
@@ -358,7 +360,13 @@ Usage:
except IOError:
self.print_color(RED, "Logfile not found.")
self.help_log()
- elif text == "more":
+ elif text[0] == "level":
+ if text[1] in ["debug", "error", "info", "warning"]:
+ self.interface.set_log_level(text[1])
+ self.print_color(GREEN, "Setting log level to: " + text[1])
+ else:
+ self.print_color(RED, "Log level " + text[1] + " not supported")
+ elif text[0] == "more":
try:
# TODO: do the more on the logfile set by args and not a static path
with open(os.path.dirname(os.path.abspath(__file__)) + "/../../log/linspector.log"):
@@ -366,7 +374,7 @@ Usage:
except IOError:
self.print_color(RED, "Logfile not found.")
self.help_log()
- elif text == "tail":
+ elif text[0] == "tail":
try:
# TODO: do the tail on the logfile set by args and not a static path
with open(os.path.dirname(os.path.abspath(__file__)) + "/../../log/linspector.log"):
@@ -378,9 +386,11 @@ Usage:
def help_log(self):
print('''
Usage:
- less less on the linspector logfile (press "q" to exit)
- more more on the linspector logfile (press "q" to exit)
- tail tail (-F) on the linspector logfile (Ctrl+C to exit)
+ less less on the linspector logfile (press "q" to exit)
+ level set the log level to
+ supported levels are debug, error, info, warning
+ more more on the linspector logfile (press "q" to exit)
+ tail tail (-F) on the linspector logfile (Ctrl+C to exit)
''')
def do_status(self, text):