summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ac7e1383..0ab44ff3 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)