summaryrefslogtreecommitdiff
path: root/src/leap/bitmask
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r--src/leap/bitmask/core/bitmaskd.tac4
-rw-r--r--src/leap/bitmask/core/launcher.py8
-rw-r--r--src/leap/bitmask/core/logs.py14
-rw-r--r--src/leap/bitmask/core/service.py3
4 files changed, 25 insertions, 4 deletions
diff --git a/src/leap/bitmask/core/bitmaskd.tac b/src/leap/bitmask/core/bitmaskd.tac
index 3c9b1d8..eba2530 100644
--- a/src/leap/bitmask/core/bitmaskd.tac
+++ b/src/leap/bitmask/core/bitmaskd.tac
@@ -2,10 +2,14 @@
# Run as: twistd -n -y bitmaskd.tac
#
from twisted.application import service
+from twisted.python.log import ILogObserver, FileLogObserver
from leap.bitmask.core.service import BitmaskBackend
+from leap.bitmask.core.logs import loggerFactory
+logger = loggerFactory()
bb = BitmaskBackend()
application = service.Application("bitmaskd")
+application.setComponent(ILogObserver, FileLogObserver(logger).emit)
bb.setServiceParent(application)
diff --git a/src/leap/bitmask/core/launcher.py b/src/leap/bitmask/core/launcher.py
index b8916a1..27e5a26 100644
--- a/src/leap/bitmask/core/launcher.py
+++ b/src/leap/bitmask/core/launcher.py
@@ -17,7 +17,7 @@
"""
Run bitmask daemon.
"""
-from os.path import join
+from os.path import join, abspath
from sys import argv
from twisted.scripts.twistd import run
@@ -25,6 +25,9 @@ from twisted.scripts.twistd import run
from leap.bitmask.util import here
from leap.bitmask import core
from leap.bitmask.core import flags
+from leap.common.config import get_path_prefix
+
+pid = abspath(join(get_path_prefix(), 'leap', 'bitmaskd.pid'))
def run_bitmaskd():
@@ -35,8 +38,7 @@ def run_bitmaskd():
flags.BACKEND = argv[index + 1]
argv[1:] = [
'-y', join(here(core), "bitmaskd.tac"),
- '--pidfile', '/tmp/bitmaskd.pid',
- '--logfile', '/tmp/bitmaskd.log',
+ '--pidfile', pid,
'--umask=0022',
]
print '[+] launching bitmaskd...'
diff --git a/src/leap/bitmask/core/logs.py b/src/leap/bitmask/core/logs.py
new file mode 100644
index 0000000..2b42d61
--- /dev/null
+++ b/src/leap/bitmask/core/logs.py
@@ -0,0 +1,14 @@
+from os.path import abspath, join, isfile
+
+from twisted.python import logfile
+
+from leap.common.config import get_path_prefix
+
+
+def loggerFactory():
+ log_path = abspath(join(get_path_prefix(), 'leap', 'bitmaskd.log'))
+ rotate = isfile(log_path)
+ _logfile = logfile.LogFile.fromFullPath(log_path, maxRotatedFiles=5)
+ if rotate:
+ _logfile.rotate()
+ return _logfile
diff --git a/src/leap/bitmask/core/service.py b/src/leap/bitmask/core/service.py
index a3eb94e..bfcf0f2 100644
--- a/src/leap/bitmask/core/service.py
+++ b/src/leap/bitmask/core/service.py
@@ -19,9 +19,10 @@ Bitmask-core Service.
"""
import json
import resource
+from os.path import join, abspath
from twisted.internet import reactor
-from twisted.python import log
+from twisted.python import log, logfile
from leap.bitmask import __version__
from leap.bitmask.core import configurable