mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-02-23 08:38:30 +00:00
Added log verbosity to config file
This commit is contained in:
parent
c9d4775085
commit
b142664ef7
|
@ -67,3 +67,8 @@ subst_youtube = []
|
||||||
# e.g. subst_reddit = ["teddit.net", ]
|
# e.g. subst_reddit = ["teddit.net", ]
|
||||||
# Default is []
|
# Default is []
|
||||||
subst_reddit = []
|
subst_reddit = []
|
||||||
|
|
||||||
|
# Verbosity of log messages
|
||||||
|
# One of DEBUG, INFO, WARNING, ERROR, CRITICAL
|
||||||
|
# Default is "WARNING"
|
||||||
|
log_level = "WARNING"
|
||||||
|
|
23
twoot.py
23
twoot.py
|
@ -38,10 +38,6 @@ from mastodon import Mastodon, MastodonError, MastodonAPIError, MastodonIllegalA
|
||||||
# Number of records to keep in db table for each twitter account
|
# Number of records to keep in db table for each twitter account
|
||||||
MAX_REC_COUNT = 50
|
MAX_REC_COUNT = 50
|
||||||
|
|
||||||
# Set the desired verbosity of logging
|
|
||||||
# One of logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL
|
|
||||||
LOGGING_LEVEL = logging.INFO
|
|
||||||
|
|
||||||
# How many seconds to wait before giving up on a download (except video download)
|
# How many seconds to wait before giving up on a download (except video download)
|
||||||
HTTPS_REQ_TIMEOUT = 10
|
HTTPS_REQ_TIMEOUT = 10
|
||||||
|
|
||||||
|
@ -94,6 +90,7 @@ def build_config(args):
|
||||||
'subst_twitter': [],
|
'subst_twitter': [],
|
||||||
'subst_youtube': [],
|
'subst_youtube': [],
|
||||||
'subst_reddit': [],
|
'subst_reddit': [],
|
||||||
|
'log_level': "WARNING"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create default config object
|
# Create default config object
|
||||||
|
@ -585,11 +582,27 @@ def main(argv):
|
||||||
# Setup logging to file
|
# Setup logging to file
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
filename=TOML['config']['twitter_account'] + '.log',
|
filename=TOML['config']['twitter_account'] + '.log',
|
||||||
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',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Set level of logging
|
||||||
|
log_level = logging.WARNING
|
||||||
|
match TOML['options']['log_level'].upper():
|
||||||
|
case 'DEBUG':
|
||||||
|
log_level = logging.DEBUG
|
||||||
|
case 'INFO':
|
||||||
|
log_level = logging.INFO
|
||||||
|
case 'WARN':
|
||||||
|
log_level = logging.WARNING
|
||||||
|
case 'ERROR':
|
||||||
|
log_level = logging.ERROR
|
||||||
|
case 'CRITICAL':
|
||||||
|
log_level = logging.CRITICAL
|
||||||
|
case _:
|
||||||
|
logging.error('Invalid log_level %s in config file. Using WARN.', str(TOML['options']['log_level']))
|
||||||
|
logging.setLevel(log_level)
|
||||||
|
|
||||||
logging.info('Running with the following configuration:')
|
logging.info('Running with the following configuration:')
|
||||||
logging.info(' Config File : ' + str(args['f']))
|
logging.info(' Config File : ' + str(args['f']))
|
||||||
logging.info(' twitter_account : ' + TOML['config']['twitter_account'])
|
logging.info(' twitter_account : ' + TOML['config']['twitter_account'])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user