Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 import sys
00025 sys.path.insert(1,"../")
00026 import unittest
00027
00028 from SystemLogger import *
00029 import OpenRTM_aist
00030
00031 i = 0
00032
00033 class TestLogger(unittest.TestCase):
00034 def setUp(self):
00035
00036
00037
00038
00039 global i
00040 i+=1
00041 self.filename = "log" + str(i) + ".log"
00042 self.logstr = LogStream("test","FILE",self.filename)
00043
00044 def tearDown(self):
00045 self.logstr.__del__()
00046 OpenRTM_aist.Manager.instance().shutdownManager()
00047 pass
00048
00049 def test_strToLogLevel(self):
00050 self.logger = Logger.init("test","FILE","test.log")
00051 self.assertEqual(self.logger.strToLogLevel("SILENT"), Logger.SILENT)
00052 self.assertEqual(self.logger.strToLogLevel("ERROR"), Logger.ERROR)
00053 self.assertEqual(self.logger.strToLogLevel("WARN"), Logger.WARN)
00054 self.assertEqual(self.logger.strToLogLevel("INFO"), Logger.INFO)
00055 self.assertEqual(self.logger.strToLogLevel("DEBUG"), Logger.DEBUG)
00056 self.assertEqual(self.logger.strToLogLevel("TRACE"), Logger.TRACE)
00057 self.assertEqual(self.logger.strToLogLevel("VERBOSE"), Logger.VERBOSE)
00058 self.assertEqual(self.logger.strToLogLevel("PARANOID"), Logger.PARANOID)
00059 self.assertEqual(self.logger.strToLogLevel("HOGE"), Logger.INFO)
00060
00061
00062 def test_addHandler(self):
00063
00064 self.logstr.setLogLevel("INFO")
00065 self.logstr.RTC_INFO("addHandler test!!!!!")
00066
00067
00068 def test_setLogLock(self):
00069 self.logstr.setLogLock(True)
00070 self.logstr.setLogLock(False)
00071
00072 def test_enableLogLock(self):
00073 self.logstr.enableLogLock()
00074
00075 def test_disableLogLock(self):
00076 self.logstr.disableLogLock()
00077
00078 def test_acquire_release(self):
00079 self.logstr.acquire()
00080 self.logstr.release()
00081
00082 def test_RTC_LOG(self):
00083 import logging
00084 self.logstr.RTC_LOG(logging.ERROR,"log %s, %s",("hoge","hogehoge"))
00085
00086
00087 def test_RTC_ERROR(self):
00088 self.logstr.RTC_ERROR("error!!!!!")
00089 def test():
00090 raise MemorryError
00091 try:
00092 test()
00093 except:
00094 self.logstr.RTC_ERROR(sys.exc_info())
00095
00096
00097 def test_RTC_WARN(self):
00098 self.logstr.RTC_WARN("warn!!!!!")
00099
00100
00101 def test_RTC_INFO(self):
00102 self.logstr.RTC_INFO("info!!!!!")
00103
00104
00105 def test_RTC_DEBUG(self):
00106 self.logstr.RTC_DEBUG("debug!!!!!")
00107
00108
00109 def test_RTC_TRACE(self):
00110 self.logstr.RTC_TRACE("trace!!!!")
00111
00112 def test_RTC_VERBOSE(self):
00113 self.logstr.RTC_VERBOSE("verbose!!!!")
00114
00115 def test_RTC_PARANOID(self):
00116 self.logstr.RTC_PARANOID("paranoid!!!!")
00117
00118
00119 if __name__ == "__main__":
00120 unittest.main()