Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

using LogFile

since DailyLogFile does not seem to support deletion of rotated log files.. kinda makes the whole rotation idea flawed
  • Loading branch information...
commit 73362dcf6d2a5d3f84ca393f3d6f182b3ba9cc47 1 parent 5d68854
@mriehl mriehl authored
View
4 src/main/python/yadtreceiver/__init__.py
@@ -32,7 +32,7 @@
from twisted.application import service
from twisted.internet import reactor
from twisted.python import log
-from twisted.python.logfile import DailyLogFile
+from twisted.python.logfile import LogFile
from yadtbroadcastclient import WampBroadcaster
@@ -221,7 +221,7 @@ def set_configuration(self, configuration):
def initialize_twisted_logging(self):
- log_file = DailyLogFile.fromFullPath(self.configuration['log_filename'])
+ log_file = LogFile.fromFullPath(self.configuration['log_filename'], maxRotatedFiles=10, rotateLength=20000000)
log.startLogging(log_file)
def startService(self):
View
11 src/unittest/python/yadtreceiver_tests.py
@@ -22,7 +22,7 @@
from mock import Mock, call, patch
from twisted.mail.scripts.mailmail import Configuration
-from twisted.python.logfile import DailyLogFile
+from twisted.python.logfile import LogFile
from yadtreceiver import __version__, Receiver, ReceiverException
from yadtreceiver.events import Event
@@ -32,7 +32,7 @@ class YadtReceiverTests (unittest.TestCase):
def test_if_this_test_fails_maybe_you_have_yadtreceiver_installed_locally(self):
self.assertEqual('${version}', __version__)
- @patch('yadtreceiver.DailyLogFile')
+ @patch('yadtreceiver.LogFile')
@patch('yadtreceiver.log')
def test_should_call_start_logging_when_initializing_twisted_logging(self, mock_log, mock_log_file_class):
receiver = Receiver()
@@ -40,12 +40,13 @@ def test_should_call_start_logging_when_initializing_twisted_logging(self, mock_
'targets': set(['devabc123']),
'broadcaster_host': 'broadcaster_host',
'broadcaster_port': 1234})
- mock_log_file = Mock(DailyLogFile)
+ mock_log_file = Mock(LogFile)
mock_log_file_class.fromFullPath.return_value = mock_log_file
receiver.initialize_twisted_logging()
- self.assertEqual(call('log/file.log'), mock_log_file_class.fromFullPath.call_args)
+ self.assertEqual(call('log/file.log', rotateLength=20000000, maxRotatedFiles=10),
+ mock_log_file_class.fromFullPath.call_args)
self.assertEquals(call(mock_log_file), mock_log.startLogging.call_args)
def test_should_set_configuration(self):
@@ -119,7 +120,7 @@ def test_should_exit_when_no_target_configured(self, mock_exit, mock_log):
self.assertEquals(call(1), mock_exit.call_args)
- @patch('yadtreceiver.DailyLogFile')
+ @patch('yadtreceiver.LogFile')
@patch('yadtreceiver.log')
def test_should_initialize_watchdog_and_start_connection_when_service_starts(self, mock_log, mock_log_file):
mock_receiver = Mock(Receiver)
Please sign in to comment.
Something went wrong with that request. Please try again.