summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/backend_app.py
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2015-06-19 14:00:28 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2015-06-22 15:52:37 -0300
commit239a0ec845d53b7a0a1af5c27b5eea956ab6459a (patch)
tree1739ad63cb2ca8a3188f307c32b09102ab8f9dd8 /src/leap/bitmask/backend_app.py
parentd75e1395c9ff3ffcb0663122140be393c7ae6b60 (diff)
[feat] handle twisted/logging logs with logbook
Forward Twisted logs to logging and use logbook to handle logging logs. Store the bitmask logs on the config folder.
Diffstat (limited to 'src/leap/bitmask/backend_app.py')
-rw-r--r--src/leap/bitmask/backend_app.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/leap/bitmask/backend_app.py b/src/leap/bitmask/backend_app.py
index 891575be..011f59fb 100644
--- a/src/leap/bitmask/backend_app.py
+++ b/src/leap/bitmask/backend_app.py
@@ -25,6 +25,7 @@ from leap.common.events import server as event_server
from leap.bitmask.backend.leapbackend import LeapBackend
from leap.bitmask.backend.utils import generate_zmq_certificates
from leap.bitmask.config import flags
+from leap.bitmask.logs.utils import get_logger
from leap.bitmask.util import dict_to_flags
@@ -54,11 +55,18 @@ def run_backend(bypass_checks=False, flags_dict=None, frontend_pid=None):
:param flags_dict: a dict containing the flag values set on app start.
:type flags_dict: dict
"""
+ # In the backend, we want all the components to log into logbook
+ # that is: logging handlers and twisted logs
+ from logbook.compat import redirect_logging
+ from twisted.python.log import PythonLoggingObserver
+ redirect_logging()
+ observer = PythonLoggingObserver()
+ observer.start()
+
# NOTE: this needs to be used here, within the call since this function is
# executed in a different process and it seems that the process/thread
# identification isn't working 100%
- from leap.bitmask.logs.utils import get_logger
- logger = get_logger()
+ logger = get_logger() # noqa
# The backend is the one who always creates the certificates. Either if it
# is run separately or in a process in the same app as the frontend.