4 new revisions:

Revision: 55e4a9158c64
Author:   Pekka Klärck
Date:     Thu Nov 10 14:25:17 2011
Log: TestCheckerLibrary: fixed overriding slots after splitting robot.resul...
http://code.google.com/p/robotframework/source/detail?r=55e4a9158c64

Revision: 4fd1152bb6fb
Author:   Pekka Klärck
Date:     Fri Nov 11 00:35:57 2011
Log:      automatically upper case log level given from cli
http://code.google.com/p/robotframework/source/detail?r=4fd1152bb6fb

Revision: b3a0975c163c
Author:   Pekka Klärck
Date:     Fri Nov 11 02:21:37 2011
Log: Configure logging module so that only message we actually are interest...
http://code.google.com/p/robotframework/source/detail?r=b3a0975c163c

Revision: 73417914e857
Author:   Pekka Klärck
Date:     Fri Nov 11 02:21:58 2011
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=73417914e857

==============================================================================
Revision: 55e4a9158c64
Author:   Pekka Klärck
Date:     Thu Nov 10 14:25:17 2011
Log: TestCheckerLibrary: fixed overriding slots after splitting robot.result.model
http://code.google.com/p/robotframework/source/detail?r=55e4a9158c64

Modified:
 /atest/resources/TestCheckerLibrary.py

=======================================
--- /atest/resources/TestCheckerLibrary.py      Wed Nov  9 09:58:40 2011
+++ /atest/resources/TestCheckerLibrary.py      Thu Nov 10 14:25:17 2011
@@ -4,7 +4,7 @@
 import robot
 from robot import utils
 from robot.result.builders import ResultFromXML
-from robot.result.model import TestSuite, TestCase, Keyword
+from robot.result import testsuite, TestSuite, TestCase, Keyword

 from robot.libraries.BuiltIn import BuiltIn

@@ -20,7 +20,7 @@
     test_class = NoSlotsTestCase
     keyword_class = NoSlotsKeyword

-robot.result.model.TestSuite = MyTestSuite
+testsuite.TestSuite = MyTestSuite


 class TestCheckerLibrary:

==============================================================================
Revision: 4fd1152bb6fb
Author:   Pekka Klärck
Date:     Fri Nov 11 00:35:57 2011
Log:      automatically upper case log level given from cli
http://code.google.com/p/robotframework/source/detail?r=4fd1152bb6fb

Modified:
 /src/robot/conf/settings.py

=======================================
--- /src/robot/conf/settings.py Wed Oct  5 05:34:12 2011
+++ /src/robot/conf/settings.py Fri Nov 11 00:35:57 2011
@@ -102,7 +102,7 @@
             return [self._process_tag_stat_combine(v) for v in value]
         if name == 'TagStatLink':
return [v for v in [self._process_tag_stat_link(v) for v in value] if v]
-        if name == 'RemoveKeywords':
+        if name in ['RemoveKeywords', 'LogLevel']:
             return value.upper()
         if name in ['SplitOutputs', 'Summary', 'SummaryTitle']:
             return self._removed_in_26(name, log)

==============================================================================
Revision: b3a0975c163c
Author:   Pekka Klärck
Date:     Fri Nov 11 02:21:37 2011
Log: Configure logging module so that only message we actually are interested are emitted.

Update issue 998
Status: Done
Fixed by configuring logging so that messages below the current log level are ignored fully.
http://code.google.com/p/robotframework/source/detail?r=b3a0975c163c

Modified:
 /atest/robot/test_libraries/logging_with_logging.txt
 /atest/testdata/test_libraries/LibUsingPyLogging.py
 /atest/testdata/test_libraries/logging_with_logging.txt
 /src/robot/__init__.py
 /src/robot/output/output.py
 /src/robot/output/pyloggingconf.py

=======================================
--- /atest/robot/test_libraries/logging_with_logging.txt Tue May 17 14:28:11 2011 +++ /atest/robot/test_libraries/logging_with_logging.txt Fri Nov 11 02:21:37 2011
@@ -1,6 +1,6 @@
 *** Settings ***
 Documentation   Tests for logging using Python's `logging` module.
-Suite Setup Run Tests ${EMPTY} test_libraries/logging_with_logging.txt +Suite Setup Run Tests -L debug test_libraries/logging_with_logging.txt
 Force Tags      regression  pybot  jybot
 Resource        atest_resource.txt

@@ -19,10 +19,13 @@

 Log with custom levels
     ${tc} =  Check test case  ${TEST NAME}
- Check log message ${tc.kws[0].msgs[0]} below debug DEBUG
-    Check log message  ${tc.kws[0].msgs[1]}  between debug and info    INFO
-    Check log message  ${tc.kws[0].msgs[2]}  between info and warning  INFO
-    Check log message  ${tc.kws[0].msgs[3]}  above warning             WARN
+ Check log message ${tc.kws[0].msgs[1]} below debug TRACE + Check log message ${tc.kws[0].msgs[2]} between debug and info DEBUG
+    Check log message  ${tc.kws[0].msgs[3]}  between info and warning  INFO
+    Check log message  ${tc.kws[0].msgs[4]}  above warning             WARN
+
+Messages below threshold level are ignored fully
+    Check test case  ${TEST NAME}

 Log using custom logger
     ${tc} =  Check test case  ${TEST NAME}
=======================================
--- /atest/testdata/test_libraries/LibUsingPyLogging.py Tue May 17 14:28:11 2011 +++ /atest/testdata/test_libraries/LibUsingPyLogging.py Fri Nov 11 02:21:37 2011
@@ -8,7 +8,6 @@
     def emit(self, record):
         sys.__stdout__.write(record.getMessage().title() + '\n')

-
 custom = logging.getLogger('custom')
 custom.addHandler(CustomHandler())
 nonprop = logging.getLogger('nonprop')
@@ -16,20 +15,38 @@
 nonprop.addHandler(CustomHandler())


+class Message(object):
+    def __init__(self, msg=''):
+        self.msg = msg
+    def __unicode__(self):
+        return self.msg
+    def __str__(self):
+        return unicode(self).encode('UTF-8')
+    def __repr__(self):
+        return repr(str(self))
+
+class InvalidMessage(Message):
+    def __unicode__(self):
+        raise AssertionError('Should not have been logged')
+
+
 def log_with_default_levels():
     logging.debug('debug message')
     logging.info('%s %s', 'info', 'message')
-    logging.warning('warning message')
+    logging.warning(Message('warning message'))
     # error and critical are considered warnings
     logging.error('error message')
     logging.critical('critical message')

 def log_with_custom_levels():
-    logging.log(logging.DEBUG-1, 'below debug')
+    logging.log(logging.DEBUG-1, Message('below debug'))
     logging.log(logging.INFO-1, 'between debug and info')
     logging.log(logging.INFO+1, 'between info and warning')
     logging.log(logging.WARNING*100, 'above warning')

+def log_invalid_message_using_debug():
+    logging.debug(InvalidMessage())
+
 def log_using_custom_logger():
     logging.getLogger('custom').info('custom logger')

=======================================
--- /atest/testdata/test_libraries/logging_with_logging.txt Tue May 17 14:28:11 2011 +++ /atest/testdata/test_libraries/logging_with_logging.txt Fri Nov 11 02:21:37 2011
@@ -1,8 +1,8 @@
 *** Settings ***
 Documentation   Tests for logging using Python's `logging` module.
 Library         LibUsingPyLogging.py
-Suite Setup     Set log level  DEBUG
-Suite Teardown  Set log level  INFO
+Test Teardown   Set Log Level  debug
+

 *** Test Cases ***

@@ -10,8 +10,13 @@
     Log with default levels

 Log with custom levels
+    [Setup]  Set log level  trace
     Log with custom levels

+Messages below threshold level are ignored fully
+    [Setup]  Set log level  info
+    Log invalid message using debug
+
 Log using custom logger
     Log using custom logger

=======================================
--- /src/robot/__init__.py      Wed Nov  2 07:50:11 2011
+++ /src/robot/__init__.py      Fri Nov 11 02:21:37 2011
@@ -117,6 +117,7 @@
     """
     STOP_SIGNAL_MONITOR.start()
     settings = RobotSettings(options)
+    pyloggingconf.initialize(settings['LogLevel'])
     LOGGER.register_console_logger(settings['MonitorWidth'],
                                    settings['MonitorColors'])
     init_global_variables(settings)
=======================================
--- /src/robot/output/output.py Mon Jul 11 06:25:04 2011
+++ /src/robot/output/output.py Fri Nov 11 02:21:37 2011
@@ -76,4 +76,8 @@
         LOGGER.log_message(msg)

     def set_log_level(self, level):
+ # TODO: Module structure should be cleaned up to prevent cyclic imports
+        import pyloggingconf
+        pyloggingconf.set_level(level)
         return self._xmllogger.set_log_level(level)
+
=======================================
--- /src/robot/output/pyloggingconf.py  Thu May 19 05:57:24 2011
+++ /src/robot/output/pyloggingconf.py  Fri Nov 11 02:21:37 2011
@@ -12,17 +12,26 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

-"""Module to configure Python's standard `logging` module.
-
-After this module is imported, messages logged with `logging` module
-are, by default, propagated to Robot's log file.
-"""
-
 import logging

 from robot.api import logger


+LEVELS = {'TRACE': logging.NOTSET,
+          'DEBUG': logging.DEBUG,
+          'INFO': logging.INFO,
+          'WARN': logging.WARNING}
+
+
+def initialize(level):
+    logging.basicConfig(level=LEVELS[level.upper()], stream=NullStream())
+    logging.getLogger().addHandler(RobotHandler())
+
+
+def set_level(level):
+    logging.getLogger().setLevel(LEVELS[level.upper()])
+
+
 class RobotHandler(logging.Handler):

     def emit(self, record):
@@ -32,9 +41,11 @@
     def _get_logger_method(self, level):
         if level >= logging.WARNING:
             return logger.warn
-        if level <= logging.DEBUG:
+        if level >= logging.INFO:
+            return logger.info
+        if level >= logging.DEBUG:
             return logger.debug
-        return logger.info
+        return logger.trace


 class NullStream(object):
@@ -47,7 +58,3 @@

     def flush(self):
         pass
-
-
-logging.basicConfig(level=logging.NOTSET, stream=NullStream())
-logging.getLogger().addHandler(RobotHandler())

==============================================================================
Revision: 73417914e857
Author:   Pekka Klärck
Date:     Fri Nov 11 02:21:58 2011
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=73417914e857


Reply via email to