Commit 163de5a7 authored by Dan Pascu's avatar Dan Pascu

Also log early notifications before SIPApplicationWillStart

parent 6820a1e2
......@@ -93,6 +93,7 @@ class Blink(QApplication):
self.first_run = False
self.main_window = MainWindow()
self.ip_address_monitor = IPAddressMonitor()
self.log_manager = LogManager()
self.update_manager = UpdateManager()
self.main_window.check_for_updates_action.triggered.connect(self.update_manager.check_for_updates)
......@@ -205,8 +206,7 @@ class Blink(QApplication):
handler(notification)
def _NH_SIPApplicationWillStart(self, notification):
log_manager = LogManager()
log_manager.start()
self.log_manager.start()
@run_in_gui_thread
def _NH_SIPApplicationDidStart(self, notification):
......
......@@ -7,11 +7,12 @@ __all__ = ['LogManager']
import os
import sys
from collections import deque
from datetime import datetime
from pprint import pformat
from application import log
from application.notification import IObserver, NotificationCenter
from application.notification import IObserver, NotificationCenter, ObserverWeakrefProxy
from application.python.queue import EventQueue
from application.python import Null
from application.python.types import Singleton
......@@ -23,6 +24,17 @@ from sipsimple.configuration.settings import SIPSimpleSettings
from blink.resources import ApplicationData
class NotificationQueue(object):
implements(IObserver)
def __init__(self):
self.notifications = deque()
NotificationCenter().add_observer(ObserverWeakrefProxy(self))
def handle_notification(self, notification):
self.notifications.append(notification)
class LogFile(object):
def __init__(self, filename):
self.filename = filename
......@@ -74,6 +86,7 @@ class LogManager(object):
self.pjsiptrace_file = Null
self.notifications_file = Null
self.event_queue = Null
self.notification_queue = NotificationQueue()
self._siptrace_start_time = None
self._siptrace_packet_count = None
......@@ -93,6 +106,10 @@ class LogManager(object):
self._siptrace_packet_count = 0
self.event_queue = EventQueue(handler=self._process_notification, name='Log handling')
self.event_queue.start()
while settings.logs.trace_notifications and self.notification_queue.notifications:
notification = self.notification_queue.notifications.popleft()
self.handle_notification(notification)
self.notification_queue = None
def stop(self):
notification_center = NotificationCenter()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment