Logging clean up

This commit is contained in:
Scott Idem
2023-07-12 13:13:35 -04:00
parent 4f7ce57111
commit 236ef204eb
3 changed files with 9 additions and 11 deletions

View File

@@ -11,7 +11,7 @@ from sqlalchemy.exc import IntegrityError, OperationalError
db_uri = settings.SQLALCHEMY_DB_URI db_uri = settings.SQLALCHEMY_DB_URI
connection_string = db_uri connection_string = db_uri
engine = create_engine(url=connection_string, pool_size=5, max_overflow=10, pool_recycle=3600, pool_pre_ping=True, echo=False, echo_pool=True, isolation_level='READ COMMITTED', connect_args={'connect_timeout': 30}) engine = create_engine(url=connection_string, pool_size=3, max_overflow=15, pool_recycle=3600, pool_pre_ping=True, echo=False, echo_pool=True, isolation_level='READ COMMITTED', connect_args={'connect_timeout': 30})
# NOTE: The default isolation_level is 'REPEATABLE READ'. This can sometimes not show updated data. # NOTE: The default isolation_level is 'REPEATABLE READ'. This can sometimes not show updated data.
# NOTE: The "echo" set to True option shows the SQL queries. # NOTE: The "echo" set to True option shows the SQL queries.

View File

@@ -27,7 +27,7 @@ def load_grant_obj(
exclude_unset: bool = True, exclude_unset: bool = True,
model_as_dict: bool = False, model_as_dict: bool = False,
) -> Grant_Ext|dict|bool: ) -> Grant_Ext|dict|bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
# if grant_id := redis_lookup_id_random(record_id_random=grant_id, table_name='grant'): pass # if grant_id := redis_lookup_id_random(record_id_random=grant_id, table_name='grant'): pass
@@ -55,10 +55,9 @@ def load_grant_obj(
log.debug(event_abstract_obj) log.debug(event_abstract_obj)
grant_obj.event_abstract = event_abstract_obj grant_obj.event_abstract = event_abstract_obj
else: else:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_abstract_obj) log.debug(event_abstract_obj)
grant_obj.event_abstract = None grant_obj.event_abstract = None
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL # log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if model_as_dict: if model_as_dict:
return grant_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member return grant_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
@@ -136,7 +135,7 @@ def get_grant_rec_list(
ORDER BY grant.priority DESC, grant.sort DESC, grant.name ASC, `grant`.created_on DESC, `grant`.updated_on DESC ORDER BY grant.priority DESC, grant.sort DESC, grant.name ASC, `grant`.created_on DESC, `grant`.updated_on DESC
{sql_limit}; {sql_limit};
""" """
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(sql) log.debug(sql)
if grant_rec_li_result := sql_select(data=data, sql=sql, as_list=True): if grant_rec_li_result := sql_select(data=data, sql=sql, as_list=True):

View File

@@ -187,7 +187,7 @@ async def get_obj_li(
response: Response = Response, response: Response = Response,
# commons: Common_Route_Params = Depends(common_route_params), # Switch to this later... sooner # commons: Common_Route_Params = Depends(common_route_params), # Switch to this later... sooner
): ):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
debug_data = {} debug_data = {}
@@ -286,7 +286,7 @@ async def get_obj(
- /order/cart/line = order_cart_line - /order/cart/line = order_cart_line
- /lu/some_lookup = lu_some_lookup - /lu/some_lookup = lu_some_lookup
""" """
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
debug_data = {} debug_data = {}
@@ -651,7 +651,7 @@ async def delete_obj(
- /order/line = order_line - /order/line = order_line
- /lu/some_lookup = lu_some_lookup - /lu/some_lookup = lu_some_lookup
""" """
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
debug_data = {} debug_data = {}
@@ -801,12 +801,11 @@ def patch_obj_template(
base_name = obj_type_li[obj_type]['base_name'] base_name = obj_type_li[obj_type]['base_name']
if sql_update_result := sql_update(table_name=table_name_update, data=obj_data): if sql_update_result := sql_update(table_name=table_name_update, data=obj_data):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(sql_update_result) log.debug(sql_update_result)
#obj_id = sql_update_result #obj_id = sql_update_result
obj_id = obj_data_dict['id'] obj_id = obj_data_dict['id']
else: else:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL # log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(sql_update_result) log.debug(sql_update_result)
return mk_resp(data=False, status_code=400, response=response) return mk_resp(data=False, status_code=400, response=response)
@@ -922,4 +921,4 @@ def delete_obj_template(
return mk_resp(data=True, response=response) return mk_resp(data=True, response=response)
else: else:
log.debug(sql_result) log.debug(sql_result)
return mk_resp(data=False, status_code=404, response=response) return mk_resp(data=False, status_code=404, response=response)