2 new revisions:

Revision: 6156dd63fcbd
Author:   Pekka Klärck
Date:     Wed Sep 21 07:31:34 2011
Log: Added new ${DATADIR} that points to atest/testdata directory to ease r...
http://code.google.com/p/robotframework/source/detail?r=6156dd63fcbd

Revision: 096c3be16f77
Author:   Pekka Klärck
Date:     Wed Sep 21 08:28:05 2011
Log: Fix problems caused by listener methods logging by writing messages ou...
http://code.google.com/p/robotframework/source/detail?r=096c3be16f77

==============================================================================
Revision: 6156dd63fcbd
Author:   Pekka Klärck
Date:     Wed Sep 21 07:31:34 2011
Log: Added new ${DATADIR} that points to atest/testdata directory to ease referencing files under that dir. Also little cleanup.
http://code.google.com/p/robotframework/source/detail?r=6156dd63fcbd

Modified:
 /atest/resources/variables.py

=======================================
--- /atest/resources/variables.py       Fri May 28 04:47:46 2010
+++ /atest/resources/variables.py       Wed Sep 21 07:31:34 2011
@@ -1,9 +1,10 @@
-import os.path
-import robot
+from os.path import abspath, dirname, join
 import tempfile
+import robot

 __all__ = ['robotpath', 'javatempdir', 'robotversion']

-robotpath = os.path.abspath(os.path.dirname(robot.__file__))
+robotpath = abspath(dirname(robot.__file__))
javatempdir = tempfile.gettempdir() # Used to be different on OSX and elsewhere
 robotversion = robot.version.get_version()
+datadir = join(dirname(__file__), '..', 'testdata')

==============================================================================
Revision: 096c3be16f77
Author:   Pekka Klärck
Date:     Wed Sep 21 08:28:05 2011
Log: Fix problems caused by listener methods logging by writing messages outside keywords into syslog instead of normal log.

Update issue 548
Status: Started
Owner: pekka.klarck
The problems with listener methods logging causing the output to be corrupt
ought to be fixed now. The fix was changing logging logic so that messages
logged when keywords are not executed are written into the syslog instead
of the normal log. Possible warnings are logged into the execution errors
section of the log file, though.

The listener methods that can log something so that it appears in the normal
log file are start_keyword, end_keyword, log_message and message (when it is
called while keywords are executed). As already mentioned, messages by other
listener methods are written to syslog.

This commit contains implementation that ought to be pretty much ready. I have
also started creating tests for this but don't have time to finalize them
right now. Finally, also the User Guide should be updated to explain how to
log from listeners and what limitations it has.
http://code.google.com/p/robotframework/source/detail?r=096c3be16f77

Modified:
 /src/robot/output/filelogger.py
 /src/robot/output/logger.py
 /src/robot/running/outputcapture.py

=======================================
--- /src/robot/output/filelogger.py     Fri Apr 15 07:52:45 2011
+++ /src/robot/output/filelogger.py     Wed Sep 21 08:28:05 2011
@@ -28,7 +28,7 @@
         return open(path, 'wb')

     def message(self, msg):
-        if self._is_logged(msg.level):
+        if self._is_logged(msg.level) and not self._writer.closed:
             entry = '%s | %s | %s\n' % (msg.timestamp, msg.level.ljust(5),
                                         msg.message)
self._writer.write(entry.replace('\n', os.linesep).encode('UTF-8'))
=======================================
--- /src/robot/output/logger.py Mon Jul 11 14:30:21 2011
+++ /src/robot/output/logger.py Wed Sep 21 08:28:05 2011
@@ -40,6 +40,7 @@
         self._message_cache = []
         self._register_console_logger()
         self._console_logger_disabled = False
+        self._started_keywords = 0

     def disable_message_cache(self):
         self._message_cache = None
@@ -96,7 +97,7 @@
         if self._message_cache is not None:
             self._message_cache.append(msg)

-    def log_message(self, msg):
+    def _log_message(self, msg):
         """Log messages written (mainly) by libraries"""
         for logger in self._loggers.all_loggers():
             logger.log_message(msg)
@@ -104,17 +105,18 @@
             msg.linkable = True
             self.message(msg)

-    _orig_log_message = log_message
+    log_message = message

     def log_output(self, output):
         for msg in StdoutLogSplitter(output):
             self.log_message(msg)

     def enable_library_import_logging(self):
+        self._prev_log_message = self.log_message
         self.log_message = self.message

     def disable_library_import_logging(self):
-        self.log_message = self._orig_log_message
+        self.log_message = self._prev_log_message

     def warn(self, msg, log=False):
         method = self.log_message if log else self.message
@@ -148,12 +150,17 @@
             logger.end_test(test)

     def start_keyword(self, keyword):
+        self._started_keywords += 1
+        self.log_message = self._log_message
         for logger in self._loggers.starting_loggers():
             logger.start_keyword(keyword)

     def end_keyword(self, keyword):
+        self._started_keywords -= 1
         for logger in self._loggers.ending_loggers():
             logger.end_keyword(keyword)
+        if not self._started_keywords:
+            self.log_message = self.message

     def __iter__(self):
         return iter(self._loggers)
=======================================
--- /src/robot/running/outputcapture.py Wed Sep 21 04:52:47 2011
+++ /src/robot/running/outputcapture.py Wed Sep 21 08:28:05 2011
@@ -23,6 +23,7 @@
     def __init__(self, library_import=False):
         if library_import:
             LOGGER.enable_library_import_logging()
+        self._library_import = library_import
         self._python_out = _PythonCapturer(stdout=True)
         self._python_err = _PythonCapturer(stdout=False)
         self._java_out = _JavaCapturer(stdout=True)
@@ -42,7 +43,8 @@
         if stderr:
             LOGGER.log_output(stderr)
             sys.__stderr__.write(stderr+'\n')
-        LOGGER.disable_library_import_logging()
+        if self._library_import:
+            LOGGER.disable_library_import_logging()

     def _release(self):
         py_out = self._python_out.release()

Reply via email to