The following code
logging.info('Collecting available features for location ' + source_feature['properties']['key'] + ' and date range [' + start_date + '..' + end_date + ']...')
feature_start_time = datetime.now()
target_directory = util.target_directory(source_feature['properties'])
if target_directory is None:
target_directory = util.target_directory_for_point(point)
try:
for layer in layers:
logging.info('Layer: \'' + layer + '\'')
print('Found dates: ', end='', flush=True)
criterion_date = end_date
while criterion_date is not None:
prints something like this
Found dates: 20170630130831 Collecting available features for location 8404222738792 and date range [2016-04-16..2017-06-30]...
20170630130831 Layer: '1_NATURAL_COL0R'
2017-06-22 2017-05-13 2017-04-23 2017-04-03 2017-03-14 2017-02-22 2017-01-23 2016-11-24 2016-10-05 2016-08-06 2016-07-17 2016-06-27 2016-06-07
i.e. print outputs interleaved with logger outputs.
How to synchronize? I wan't logs printed in the same moment as they called and doesn't interleave with print's.
UPDATE
Logging initialized with following
import logging
logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%Y%m%d%H%M%S', level=logging.INFO)