Minor improvement to logging

This commit is contained in:
jeancf 2022-09-14 16:54:47 +02:00
parent 5e0fb1a9c3
commit 7f462a5a6e

View File

@ -34,6 +34,10 @@ from mastodon import Mastodon, MastodonError, MastodonAPIError, MastodonIllegalA
import subprocess import subprocess
import shutil import shutil
# Set the desired verbosity of logging
# One of logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL
LOGGING_LEVEL = logging.INFO
NITTER_URLS = [ NITTER_URLS = [
'https://nitter.42l.fr', 'https://nitter.42l.fr',
'https://nitter.pussthecat.org', 'https://nitter.pussthecat.org',
@ -236,10 +240,10 @@ def login(instance, account, password):
sys.exit(-1) sys.exit(-1)
# Check ratelimit status # Check ratelimit status
logging.info('Ratelimit allowed requests: ' + str(mastodon.ratelimit_limit)) logging.debug('Ratelimit allowed requests: ' + str(mastodon.ratelimit_limit))
logging.info('Ratelimit remaining requests: ' + str(mastodon.ratelimit_remaining)) logging.debug('Ratelimit remaining requests: ' + str(mastodon.ratelimit_remaining))
logging.info('Ratelimit reset time: ' + time.asctime(time.localtime(mastodon.ratelimit_reset))) logging.debug('Ratelimit reset time: ' + time.asctime(time.localtime(mastodon.ratelimit_reset)))
logging.info('Ratelimit last call: ' + time.asctime(time.localtime(mastodon.ratelimit_lastcall))) logging.debug('Ratelimit last call: ' + time.asctime(time.localtime(mastodon.ratelimit_lastcall)))
return mastodon return mastodon
@ -282,7 +286,7 @@ def main(argv):
# Setup logging to file # Setup logging to file
logging.basicConfig( logging.basicConfig(
filename=twit_account + '.log', filename=twit_account + '.log',
level=logging.INFO, level=LOGGING_LEVEL,
format='%(asctime)s %(levelname)-8s %(message)s', format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S', datefmt='%Y-%m-%d %H:%M:%S',
) )