File size: 583 Bytes
4589b64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import pytz
import logging
import datetime

def get_logging(log_dir):
    """Get logging function

    Args:
        log_dir (String): location directory (relative path)

    Returns:
        logging: custom logging
    """
    
    logging.Formatter.converter = logging.Formatter.converter = lambda *args: datetime.datetime.now(tz=pytz.timezone('Asia/Ho_Chi_Minh')).timetuple()
    logging.basicConfig(filename=log_dir, level=logging.INFO, format = '[%(asctime)s] - [%(levelname)s] - [%(funcName)s] - [%(lineno)d] - %(message)s',
                    filemode="w")
    return logging