mirror of
https://github.com/3cky/mbusd.git
synced 2024-09-27 03:53:02 +02:00
tests: better logging for all testcases
This commit is contained in:
parent
ecf63b992b
commit
ae360073bf
@ -8,6 +8,7 @@ The asynchronous server is a high performance implementation using the
|
||||
twisted library as its backend. This allows it to scale to many thousands
|
||||
of nodes which can be helpful for testing monitoring software.
|
||||
'''
|
||||
import logging
|
||||
#---------------------------------------------------------------------------#
|
||||
# import the various server implementations
|
||||
#---------------------------------------------------------------------------#
|
||||
@ -26,10 +27,7 @@ class ModbusSerialServer:
|
||||
#---------------------------------------------------------------------------#
|
||||
# configure the service logging
|
||||
#---------------------------------------------------------------------------#
|
||||
import logging
|
||||
logging.basicConfig()
|
||||
log = logging.getLogger()
|
||||
log.setLevel(logging.DEBUG)
|
||||
log = logging.getLogger("ModbusServer")
|
||||
|
||||
serialPort = readlink('/tmp/pts1')
|
||||
|
||||
@ -126,9 +124,8 @@ class ModbusSerialServer:
|
||||
self.p.start()
|
||||
print("p.start done")
|
||||
|
||||
|
||||
def kill(self):
|
||||
print("Going to terminate the process, this could throw exceptions")
|
||||
self.log.info("Going to terminate the process, this could throw exceptions")
|
||||
if self.p is not None:
|
||||
self.p.terminate()
|
||||
|
||||
|
@ -106,4 +106,10 @@ class TestModbusRequests(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
import logging
|
||||
stdout_handler = logging.StreamHandler(sys.stdout)
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format=u'[%(asctime)s] %(name)-26s-%(levelname)-5s %(funcName)-20s:%(lineno)-4d \033[35m%(message)s\033[0m',
|
||||
datefmt='%d.%m. %H:%M:%S',
|
||||
handlers=[stdout_handler])
|
||||
unittest.main(verbosity=2)
|
Loading…
Reference in New Issue
Block a user