summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2016-11-04 21:51:10 -0200
committerdrebs <drebs@riseup.net>2016-11-06 14:21:08 -0200
commit0ed9a016f6b41600f6bfc7b6576f152e6bf6a902 (patch)
tree250e20ebce8bede4cc36e54e5b8f251d3f7ce38a /src/leap
parentb815b0958973d10f12df45fb8e9e501deb377a24 (diff)
[feat] allow for decreased verbosity
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/core/bitmaskd.tac11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/leap/bitmask/core/bitmaskd.tac b/src/leap/bitmask/core/bitmaskd.tac
index ac7e138..0ab44ff 100644
--- a/src/leap/bitmask/core/bitmaskd.tac
+++ b/src/leap/bitmask/core/bitmaskd.tac
@@ -1,9 +1,15 @@
# Service composition for bitmask-core.
# Run as: twistd -n -y bitmaskd.tac
#
+
+import os
+
from twisted.application import service
from twisted.logger import ILogObserver
from twisted.logger import FileLogObserver
+from twisted.logger import FilteringLogObserver
+from twisted.logger import LogLevel
+from twisted.logger import LogLevelFilterPredicate
from twisted.logger import formatEventAsClassicLogText as formatEvent
from leap.bitmask.core.service import BitmaskBackend
@@ -14,7 +20,10 @@ application = service.Application("bitmaskd")
# configure logging
log_file = logFileFactory()
-observer = FileLogObserver(log_file, formatEvent)
+file_observer = FileLogObserver(log_file, formatEvent)
+level = LogLevel.debug if os.environ.get('BITMASK_DEBUG') else LogLevel.info
+predicate = LogLevelFilterPredicate(defaultLogLevel=level)
+observer = FilteringLogObserver(file_observer, [predicate])
application.setComponent(ILogObserver, observer)
bb.setServiceParent(application)