Merge "Added configure_tempest() function"
[functest.git] / testcases / Controllers / ONOS / Teston / CI / adapters / foundation.py
1 """
2 Description:
3     This file include basis functions
4     lanqinglong@huawei.com
5 """
6
7 import logging
8 import os
9 import time
10
11 class foundation:
12
13     def __init__(self):
14         self.dir = os.path.join( os.getcwd(), 'log' )
15
16     def log (self, loginfo):
17         """
18         Record log in log directory for deploying test environment
19         parameters:
20         loginfo(input): record info
21         """
22         filename = time.strftime( '%Y-%m-%d-%H-%M-%S' ) + '.log'
23         filepath = os.path.join( self.dir, filename )
24         logging.basicConfig( level=logging.INFO,
25                 format = '%(asctime)s %(filename)s:%(message)s',
26                 datefmt = '%d %b %Y %H:%M:%S',
27                 filename = filepath,
28                 filemode = 'w')
29         filelog = logging.FileHandler( filepath )
30         logging.getLogger( 'Functest' ).addHandler( filelog )
31         print loginfo
32         logging.info(loginfo)