test_SystemLogger.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- Python -*-
3 
4 # @file test_SystemLogger.py
5 # @brief test for RT component logger class
6 # @date $Date$
7 # @author Shinji Kurihara
8 #
9 # Copyright (C) 2003-2005
10 # Task-intelligence Research Group,
11 # Intelligent Systems Research Institute,
12 # National Institute of
13 # Advanced Industrial Science and Technology (AIST), Japan
14 # All rights reserved.
15 #
16 # $Id$
17 #
18 
19 #
20 # $Log$
21 #
22 #
23 
24 import sys
25 sys.path.insert(1,"../")
26 import unittest
27 
28 from SystemLogger import *
29 import OpenRTM_aist
30 
31 i = 0
32 
33 class TestLogger(unittest.TestCase):
34  def setUp(self):
35 
36  #import random
37  #val = random.uniform(0,100)
38  #self.filename = "log" + str(val) + ".log"
39  global i
40  i+=1
41  self.filename = "log" + str(i) + ".log"
42  self.logstr = LogStream("test","FILE",self.filename)
43 
44  def tearDown(self):
45  self.logstr.__del__()
46  OpenRTM_aist.Manager.instance().shutdownManager()
47  pass
48 
49  def test_strToLogLevel(self):
50  self.logger = Logger.init("test","FILE","test.log")
51  self.assertEqual(self.logger.strToLogLevel("SILENT"), Logger.SILENT)
52  self.assertEqual(self.logger.strToLogLevel("ERROR"), Logger.ERROR)
53  self.assertEqual(self.logger.strToLogLevel("WARN"), Logger.WARN)
54  self.assertEqual(self.logger.strToLogLevel("INFO"), Logger.INFO)
55  self.assertEqual(self.logger.strToLogLevel("DEBUG"), Logger.DEBUG)
56  self.assertEqual(self.logger.strToLogLevel("TRACE"), Logger.TRACE)
57  self.assertEqual(self.logger.strToLogLevel("VERBOSE"), Logger.VERBOSE)
58  self.assertEqual(self.logger.strToLogLevel("PARANOID"), Logger.PARANOID)
59  self.assertEqual(self.logger.strToLogLevel("HOGE"), Logger.INFO)
60 
61 
62  def test_addHandler(self):
63  #self.logstr.addHandler("stdout")
64  self.logstr.setLogLevel("INFO")
65  self.logstr.RTC_INFO("addHandler test!!!!!")
66 
67 
68  def test_setLogLock(self):
69  self.logstr.setLogLock(True)
70  self.logstr.setLogLock(False)
71 
72  def test_enableLogLock(self):
73  self.logstr.enableLogLock()
74 
76  self.logstr.disableLogLock()
77 
79  self.logstr.acquire()
80  self.logstr.release()
81 
82  def test_RTC_LOG(self):
83  import logging
84  self.logstr.RTC_LOG(logging.ERROR,"log %s, %s",("hoge","hogehoge"))
85 
86 
87  def test_RTC_ERROR(self):
88  self.logstr.RTC_ERROR("error!!!!!")
89  def test():
90  raise MemorryError
91  try:
92  test()
93  except:
94  self.logstr.RTC_ERROR(sys.exc_info())
95 
96 
97  def test_RTC_WARN(self):
98  self.logstr.RTC_WARN("warn!!!!!")
99 
100 
101  def test_RTC_INFO(self):
102  self.logstr.RTC_INFO("info!!!!!")
103 
104 
105  def test_RTC_DEBUG(self):
106  self.logstr.RTC_DEBUG("debug!!!!!")
107 
108 
109  def test_RTC_TRACE(self):
110  self.logstr.RTC_TRACE("trace!!!!")
111 
112  def test_RTC_VERBOSE(self):
113  self.logstr.RTC_VERBOSE("verbose!!!!")
114 
115  def test_RTC_PARANOID(self):
116  self.logstr.RTC_PARANOID("paranoid!!!!")
117 
118 
119 if __name__ == "__main__":
120  unittest.main()


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Mon Feb 28 2022 23:01:07