# -*- coding: utf-8 -*- """ Created on Mon Jan 8 17:05:21 2018 @author: hanye """ import logging from func_build_maintainance_index import build_maintainance_index import datetime # define logger logger=logging.getLogger('maintainance_build_manual') logger.setLevel(logging.DEBUG) # create handler path='/home/hanye/project_data/Python/Projects/proj-short-videos/write-data-into-es/log/' log_fn='build_maintainance_%s_log' % datetime.datetime.now().isoformat().replace(':','-') fh=logging.FileHandler(path+log_fn) fh.setLevel(logging.INFO) # create formatter and add it to the handler formatter=logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) # add handler to logger logger.addHandler(fh) logger.info('log starts at %s', datetime.datetime.now()) fetch_year=2017 #fetch_month=1 for fetch_month in range(7, 12): days_of_the_month=(datetime.datetime(fetch_year, fetch_month+1, 1)-datetime.timedelta(days=1)).day for fetch_day in range(1, days_of_the_month+1): build_maintainance_index(fetch_year, fetch_month, fetch_day)