2 new revisions:

Revision: 6fe2b76ed408
Author:   Pekka Klärck
Date:     Fri Nov 11 05:57:18 2011
Log: pyloggingconf: 1) Fixed handlig NONE level an invalid levels. 2) Simpl...
http://code.google.com/p/robotframework/source/detail?r=6fe2b76ed408

Revision: 694ba7acff06
Author:   Pekka Klärck
Date:     Fri Nov 11 05:58:39 2011
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=694ba7acff06

==============================================================================
Revision: 6fe2b76ed408
Author:   Pekka Klärck
Date:     Fri Nov 11 05:57:18 2011
Log: pyloggingconf: 1) Fixed handlig NONE level an invalid levels. 2) Simplified config.
http://code.google.com/p/robotframework/source/detail?r=6fe2b76ed408

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/output/pyloggingconf.py

=======================================
--- /atest/robot/test_libraries/logging_with_logging.txt Fri Nov 11 02:21:37 2011 +++ /atest/robot/test_libraries/logging_with_logging.txt Fri Nov 11 05:57:18 2011
@@ -1,10 +1,15 @@
 *** Settings ***
 Documentation   Tests for logging using Python's `logging` module.
-Suite Setup Run Tests -L debug test_libraries/logging_with_logging.txt
+Suite Setup     Run Tests  -L none  test_libraries/logging_with_logging.txt
 Force Tags      regression  pybot  jybot
 Resource        atest_resource.txt

 *** Test Cases ***
+
+All logging is disabled
+    ${tc} =  Check test case  ${TEST NAME}
+    Should be empty  ${tc.kws[0].msgs}
+    Should be empty  ${tc.kws[1].msgs}

 Log with default levels
     ${tc} =  Check test case  ${TEST NAME}
@@ -39,6 +44,7 @@

 Timestamps are accurate
     ${tc} =  Check test case  ${TEST NAME}
+    Length Should Be  ${tc.kws[0].msgs}  2
     ${msg1}  ${msg2} =  Set variable  ${tc.kws[0].msgs}
     Check log message  ${msg1}  First message
     Check log message  ${msg2}  Second message 0.1 sec later
=======================================
--- /atest/testdata/test_libraries/LibUsingPyLogging.py Fri Nov 11 02:21:37 2011 +++ /atest/testdata/test_libraries/LibUsingPyLogging.py Fri Nov 11 05:57:18 2011
@@ -44,8 +44,8 @@
     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_invalid_message():
+    logging.info(InvalidMessage())

 def log_using_custom_logger():
     logging.getLogger('custom').info('custom logger')
=======================================
--- /atest/testdata/test_libraries/logging_with_logging.txt Fri Nov 11 02:21:37 2011 +++ /atest/testdata/test_libraries/logging_with_logging.txt Fri Nov 11 05:57:18 2011
@@ -6,6 +6,10 @@

 *** Test Cases ***

+All logging is disabled
+    Log with default levels
+    Log invalid message
+
 Log with default levels
     Log with default levels

@@ -14,8 +18,8 @@
     Log with custom levels

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

 Log using custom logger
     Log using custom logger
=======================================
--- /src/robot/output/pyloggingconf.py  Fri Nov 11 02:21:37 2011
+++ /src/robot/output/pyloggingconf.py  Fri Nov 11 05:57:18 2011
@@ -24,12 +24,16 @@


 def initialize(level):
-    logging.basicConfig(level=LEVELS[level.upper()], stream=NullStream())
     logging.getLogger().addHandler(RobotHandler())
+    set_level(level)


 def set_level(level):
-    logging.getLogger().setLevel(LEVELS[level.upper()])
+    try:
+        level = LEVELS[level.upper()]
+    except KeyError:
+        return
+    logging.getLogger().setLevel(level)


 class RobotHandler(logging.Handler):
@@ -46,15 +50,3 @@
         if level >= logging.DEBUG:
             return logger.debug
         return logger.trace
-
-
-class NullStream(object):
-
-    def write(self, message):
-        pass
-
-    def close(self):
-        pass
-
-    def flush(self):
-        pass

==============================================================================
Revision: 694ba7acff06
Author:   Pekka Klärck
Date:     Fri Nov 11 05:58:39 2011
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=694ba7acff06


Reply via email to