From 501005d7d54bd57a37df4777154f0e47e4dc622c Mon Sep 17 00:00:00 2001 From: drebs Date: Sun, 6 Nov 2016 12:58:01 -0200 Subject: [feat] increase verbosity using command line --- src/leap/bitmask/cli/bitmask_cli.py | 6 +++++- src/leap/bitmask/core/bitmaskd.tac | 3 ++- src/leap/bitmask/core/flags.py | 1 + src/leap/bitmask/core/launcher.py | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/leap') diff --git a/src/leap/bitmask/cli/bitmask_cli.py b/src/leap/bitmask/cli/bitmask_cli.py index c27cabf..4f275d9 100755 --- a/src/leap/bitmask/cli/bitmask_cli.py +++ b/src/leap/bitmask/cli/bitmask_cli.py @@ -92,7 +92,11 @@ GENERAL COMMANDS: # XXX careful! Should see if the process in PID is running, # avoid launching again. import commands - commands.getoutput('bitmaskd') + cmd = 'bitmaskd' + if raw_args and '--verbose' in raw_args: + cmd += ' --verbose' + commands.getoutput(cmd) + command.default_dict_printer({'start': 'ok'}) return defer.succeed(None) def version(self, raw_args): diff --git a/src/leap/bitmask/core/bitmaskd.tac b/src/leap/bitmask/core/bitmaskd.tac index 0ab44ff..e2733f9 100644 --- a/src/leap/bitmask/core/bitmaskd.tac +++ b/src/leap/bitmask/core/bitmaskd.tac @@ -12,6 +12,7 @@ from twisted.logger import LogLevel from twisted.logger import LogLevelFilterPredicate from twisted.logger import formatEventAsClassicLogText as formatEvent +from leap.bitmask.core import flags from leap.bitmask.core.service import BitmaskBackend from leap.bitmask.core.logs import logFileFactory @@ -21,7 +22,7 @@ application = service.Application("bitmaskd") # configure logging log_file = logFileFactory() file_observer = FileLogObserver(log_file, formatEvent) -level = LogLevel.debug if os.environ.get('BITMASK_DEBUG') else LogLevel.info +level = LogLevel.debug if flags.VERBOSE else LogLevel.info predicate = LogLevelFilterPredicate(defaultLogLevel=level) observer = FilteringLogObserver(file_observer, [predicate]) application.setComponent(ILogObserver, observer) diff --git a/src/leap/bitmask/core/flags.py b/src/leap/bitmask/core/flags.py index 9a40c70..12905d3 100644 --- a/src/leap/bitmask/core/flags.py +++ b/src/leap/bitmask/core/flags.py @@ -1 +1,2 @@ BACKEND = 'default' +VERBOSE = False diff --git a/src/leap/bitmask/core/launcher.py b/src/leap/bitmask/core/launcher.py index a02cb23..d77f367 100644 --- a/src/leap/bitmask/core/launcher.py +++ b/src/leap/bitmask/core/launcher.py @@ -50,6 +50,8 @@ def run_bitmaskd(): for (index, arg) in enumerate(sys.argv): if arg == '--backend': flags.BACKEND = sys.argv[index + 1] + elif arg == '--verbose': + flags.VERBOSE = True args = [ '-y', join(here(core), "bitmaskd.tac"), '--logfile', getLogPath(), -- cgit v1.2.3