summaryrefslogtreecommitdiffstats
path: root/testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
blob: 2d6b87684253cfa98aa7a57ba0c56e11cd4d4a2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Description:
    This file include basis functions
    lanqinglong@huawei.com
"""

import logging
import os
import time

class foundation:

    def __init__(self):
        self.dir = os.path.join( os.getcwd(), 'log' )

    def log (self, loginfo):
        """
        Record log in log directory for deploying test environment
        parameters:
        loginfo(input): record info
        """
        filename = time.strftime( '%Y-%m-%d-%H-%M-%S' ) + '.log'
        filepath = os.path.join( self.dir, filename )
        logging.basicConfig( level=logging.INFO,
                format = '%(asctime)s %(filename)s:%(message)s',
                datefmt = '%d %b %Y %H:%M:%S',
                filename = filepath,
                filemode = 'w')
        filelog = logging.FileHandler( filepath )
        logging.getLogger( 'Functest' ).addHandler( filelog )
        print loginfo
        logging.info(loginfo)