forked from LiveCarta/BookConverter
update logging errors
This commit is contained in:
@@ -41,7 +41,7 @@ def convert_book(book_id, access, logger, libra_locker):
|
|||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
logger.info(f'Book-{book_id} has been proceeded.')
|
logger.info(f'Book-{book_id} has been proceeded.')
|
||||||
# print('Book has been proceeded.')
|
print('Book has been proceeded.')
|
||||||
|
|
||||||
|
|
||||||
def callback(ch, method, properties, body, logger, libra_locker):
|
def callback(ch, method, properties, body, logger, libra_locker):
|
||||||
@@ -67,12 +67,10 @@ def callback(ch, method, properties, body, logger, libra_locker):
|
|||||||
if hasattr(exc, 'message'):
|
if hasattr(exc, 'message'):
|
||||||
logger.error(f'{sys.exc_info()[0]}: {exc.message}')
|
logger.error(f'{sys.exc_info()[0]}: {exc.message}')
|
||||||
else:
|
else:
|
||||||
logger.error(f'{sys.exc_info()[0]}')
|
logger.error(f'{sys.exc_info()[0]}: {str(exc)}')
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
pass
|
pass
|
||||||
# thread.join()
|
|
||||||
# print('Waiting for the message...')
|
|
||||||
|
|
||||||
|
|
||||||
def local_convert_book(filename, locker):
|
def local_convert_book(filename, locker):
|
||||||
@@ -107,21 +105,24 @@ def local_run(books):
|
|||||||
|
|
||||||
|
|
||||||
def server_run():
|
def server_run():
|
||||||
|
logger = configure_file_logger('consumer', logging_format='%(asctime)s - %(levelname)s - %(message)s')
|
||||||
|
|
||||||
folder_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
folder_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
# config_path = Path(os.path.join(folder_path, "config/config.json"))
|
|
||||||
config_path = Path(os.path.join(folder_path, "config/queue_config.json"))
|
config_path = Path(os.path.join(folder_path, "config/queue_config.json"))
|
||||||
with open(config_path, "r") as f:
|
with open(config_path, "r") as f:
|
||||||
conf_param = json.load(f)
|
conf_param = json.load(f)
|
||||||
|
|
||||||
host = conf_param.get('host') or pika.ConnectionParameters().DEFAULT_HOST
|
host = conf_param.get('host') or pika.ConnectionParameters().DEFAULT_HOST
|
||||||
port = conf_param.get('port') or pika.ConnectionParameters().DEFAULT_PORT
|
port = conf_param.get('port') or pika.ConnectionParameters().DEFAULT_PORT
|
||||||
|
channel = None
|
||||||
credentials = pika.PlainCredentials(username=conf_param['username'], password=conf_param['password'])
|
try:
|
||||||
parameters = pika.ConnectionParameters(host=host, port=port, credentials=credentials)
|
credentials = pika.PlainCredentials(username=conf_param['username'], password=conf_param['password'])
|
||||||
connection = pika.BlockingConnection(parameters)
|
parameters = pika.ConnectionParameters(host=host, port=port, credentials=credentials)
|
||||||
channel = connection.channel()
|
connection = pika.BlockingConnection(parameters)
|
||||||
|
channel = connection.channel()
|
||||||
logger = configure_file_logger('consumer', logging_format='%(asctime)s - %(levelname)s - %(message)s')
|
except Exception as exc:
|
||||||
|
logger.log(logging.ERROR, f'Problems with queue connection.\n' + str(exc))
|
||||||
|
raise exc
|
||||||
|
|
||||||
try:
|
try:
|
||||||
channel.queue_declare(queue=conf_param['queue'], durable=True, arguments={'x-max-priority': 10})
|
channel.queue_declare(queue=conf_param['queue'], durable=True, arguments={'x-max-priority': 10})
|
||||||
|
|||||||
Reference in New Issue
Block a user