Logging module to write test cases:

Time Import 
# Loginfo defined class
class Loginfo (Object):
# define enable logging:
DEF the __init __ (Self, path = "", MODE = "W"):
fname = + The time.strftime path ( "% Y-M-% D% ", time.gmtime ())
self.log = Open (path + + fname" .txt ", MODE, encoding =" UTF-. 8 ")
# defines the write log feature:
DEF log_write (Self, MSG):
Self .log.write (MSG)
# define logging off:
DEF log_close (Self):
self.log.close ()
IF the __name__ == '__main__':
log = loginfo ()
log.log_write ( "test loginfo test")
log .log_close ()

Guess you like

Origin www.cnblogs.com/zhang-da/p/12082566.html