Use vlogging.

This commit is contained in:
voussoir 2021-03-23 12:15:31 -07:00
parent fb8de24a9d
commit 695507bcec
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -1,7 +1,6 @@
import argparse import argparse
import datetime import datetime
import gzip import gzip
import logging
import PIL.Image import PIL.Image
import random import random
import requests import requests
@ -10,11 +9,9 @@ import sys
import time import time
from voussoirkit import threadpool from voussoirkit import threadpool
from voussoirkit import vlogging
logging.basicConfig(level=logging.DEBUG) log = vlogging.getLogger(__name__, 'pixelcanvasdl')
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
logging.getLogger('urllib3.connectionpool').setLevel(logging.CRITICAL)
WHITE = (255, 255, 255) WHITE = (255, 255, 255)
LIGHTGRAY = (228, 228, 228) LIGHTGRAY = (228, 228, 228)
@ -164,7 +161,7 @@ def download_bigchunk(bigchunk_x, bigchunk_y):
Download a bigchunk and return the list of chunks. Download a bigchunk and return the list of chunks.
''' '''
url = url_for_bigchunk(bigchunk_x, bigchunk_y) url = url_for_bigchunk(bigchunk_x, bigchunk_y)
logging.info('Downloading %s', url) log.info('Downloading %s', url)
response = request(url) response = request(url)
bigchunk_data = response.content bigchunk_data = response.content
if len(bigchunk_data) != BIGCHUNK_SIZE_BYTES: if len(bigchunk_data) != BIGCHUNK_SIZE_BYTES:
@ -179,6 +176,7 @@ def download_bigchunk_range(bigchunk_xy1, bigchunk_xy2, shuffle=False, threads=1
Given (UPPERLEFT_X, UPPERLEFT_Y), (LOWERRIGHT_X, LOWERRIGHT_Y), Given (UPPERLEFT_X, UPPERLEFT_Y), (LOWERRIGHT_X, LOWERRIGHT_Y),
download multiple bigchunks, and yield all of the small chunks. download multiple bigchunks, and yield all of the small chunks.
''' '''
log.debug('Downloading bigchunk range %s-%s', bigchunk_xy1, bigchunk_xy2)
bigchunks = bigchunk_range_iterator(bigchunk_xy1, bigchunk_xy2) bigchunks = bigchunk_range_iterator(bigchunk_xy1, bigchunk_xy2)
if shuffle: if shuffle:
@ -547,6 +545,9 @@ def update_argparse(args):
sql.commit() sql.commit()
def main(argv): def main(argv):
argv = vlogging.set_level_by_argv(log, argv)
vlogging.getLogger('urllib3.connectionpool').setLevel(vlogging.CRITICAL)
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers() subparsers = parser.add_subparsers()