File size: 826 Bytes
922e494
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import logging


def get_logger(path, *args, **kwargs):
    # logger = logging.getLogger('train')
    # logger.setLevel(logging.NOTSET)
    # formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    # # add filehandler
    # fh = logging.FileHandler(path)
    # fh.setLevel(logging.NOTSET)
    # fh.setFormatter(formatter)
    # ch = logging.StreamHandler()
    # ch.setLevel(logging.ERROR)
    # logger.addHandler(fh)
    # logger.addHandler(ch)
    # return logger
    logging.basicConfig(format = '%(asctime)s %(message)s',
                    datefmt = '%m/%d/%Y %I:%M:%S %p',
                    handlers=[
                        logging.FileHandler(path),
                        logging.StreamHandler()
                    ],
                    level=logging.DEBUG)
    return logging