Skip to content

Commit

Permalink
Grumble: deprecated get_additional_metadata and fixed sqlalchemy logg…
Browse files Browse the repository at this point in the history
…ing verbosity (#342) (#343)
  • Loading branch information
signebedi committed Sep 5, 2024
1 parent 2f5530f commit f157fa1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions libreforms_fastapi/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,14 @@ async def authenticate(self, request):
logger = set_logger(
environment=config.ENVIRONMENT,
log_file_name='uvicorn.log',
namespace='uvicorn.error'
namespace='uvicorn.error',
)

sqlalchemy_logger = set_logger(
environment=config.ENVIRONMENT,
log_file_name='sqlalchemy.log',
namespace='sqlalchemy.engine'
namespace='sqlalchemy.engine',
log_level=logging.ERROR,
)

# document_database_logger = set_logger(
Expand Down
4 changes: 2 additions & 2 deletions libreforms_fastapi/utils/logging.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os, logging


def set_logger(environment, log_file_name, namespace, log_directory=os.path.join(os.getcwd(), 'instance', 'log'), write_to_file:bool=True):
def set_logger(environment, log_file_name, namespace, log_directory=os.path.join(os.getcwd(), 'instance', 'log'), write_to_file:bool=True, log_level=logging.INFO):
logger = logging.getLogger(namespace)
logger.setLevel(logging.INFO)
logger.setLevel(log_level)

# if environment == "production":
if write_to_file and environment != "testing":
Expand Down
2 changes: 1 addition & 1 deletion libreforms_fastapi/utils/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ class Config:
# return user_fields, form_fields

# Attach the method to the dynamic model
dynamic_model.get_additional_metadata = get_additional_metadata
# dynamic_model.get_additional_metadata = get_additional_metadata

# Attach event hook attr to the dynamic model, see
# https://github.com/signebedi/libreforms-fastapi/issues/210
Expand Down

0 comments on commit f157fa1

Please sign in to comment.