From fa37f7d40a040bf380530919e139cc9a89e912d6 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 13 Jun 2013 12:15:59 +0200 Subject: [PATCH] Add some logging to core messaging --- couchpotato/core/notifications/core/main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/notifications/core/main.py b/couchpotato/core/notifications/core/main.py index e45c4092..44d0e9b3 100644 --- a/couchpotato/core/notifications/core/main.py +++ b/couchpotato/core/notifications/core/main.py @@ -10,6 +10,7 @@ from couchpotato.environment import Env from sqlalchemy.sql.expression import or_ import threading import time +import traceback import uuid log = CPLog(__name__) @@ -146,6 +147,8 @@ class CoreNotifier(Notification): def frontend(self, type = 'notification', data = {}, message = None): + log.debug('Notifying frontend') + self.m_lock.acquire() notification = { 'message_id': str(uuid.uuid4()), @@ -164,11 +167,14 @@ class CoreNotifier(Notification): 'result': [notification], }) except: + log.debug('Failed sending to listener: %s', traceback.format_exc()) break self.m_lock.release() self.cleanMessages() + log.debug('Done notifying frontend') + def addListener(self, callback, last_id = None): if last_id: @@ -190,9 +196,11 @@ class CoreNotifier(Notification): if listener == callback: self.listeners.remove(list_tuple) except: - pass + log.debug('Failed removing listener: %s', traceback.format_exc()) def cleanMessages(self): + + log.debug('Cleaning messages') self.m_lock.acquire() for message in self.messages: @@ -200,8 +208,11 @@ class CoreNotifier(Notification): self.messages.remove(message) self.m_lock.release() + log.debug('Done cleaning messages') def getMessages(self, last_id): + + log.debug('Getting messages with id: %s', last_id) self.m_lock.acquire() recent = [] @@ -212,6 +223,7 @@ class CoreNotifier(Notification): recent = self.messages[index:] self.m_lock.release() + log.debug('Returning for %s %s messages', (last_id, len(recent or []))) return recent or []