Skip to content

Commit

Permalink
Modify Logging Levels for Read-only actions (#5647)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertKeyser authored Jan 6, 2025
1 parent 0214492 commit 22c05f2
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 34 deletions.
12 changes: 6 additions & 6 deletions src/fides/api/api/v1/endpoints/dataset_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
def _get_connection_config(
connection_key: FidesKey, db: Session = Depends(deps.get_db)
) -> ConnectionConfig:
logger.info("Finding connection config with key '{}'", connection_key)
logger.debug("Finding connection config with key '{}'", connection_key)
connection_config = ConnectionConfig.get_by(db, field="key", value=connection_key)
if not connection_config:
raise HTTPException(
Expand Down Expand Up @@ -509,7 +509,7 @@ def get_datasets(
Soon to be deprecated.
"""

logger.info(
logger.debug(
"Finding all datasets for connection '{}' with pagination params {}",
connection_config.key,
params,
Expand Down Expand Up @@ -544,7 +544,7 @@ def get_dataset(
Soon to be deprecated
"""

logger.info(
logger.debug(
"Finding dataset '{}' for connection '{}'", fides_key, connection_config.key
)
dataset_config = DatasetConfig.filter(
Expand Down Expand Up @@ -574,7 +574,7 @@ def get_dataset_configs(
) -> AbstractPage[DatasetConfig]:
"""Returns all Dataset Configs attached to current Connection Config."""

logger.info(
logger.debug(
"Finding all dataset configs for connection '{}' with pagination params {}",
connection_config.key,
params,
Expand All @@ -598,7 +598,7 @@ def get_dataset_config(
) -> DatasetConfig:
"""Returns the specific Dataset Config linked to the Connection Config."""

logger.info(
logger.debug(
"Finding dataset config '{}' for connection '{}'",
fides_key,
connection_config.key,
Expand Down Expand Up @@ -669,7 +669,7 @@ def get_ctl_datasets(
Returns all CTL datasets .
"""

logger.info(
logger.debug(
f"Finding all datasets {remove_saas_datasets=} {only_unlinked_datasets=}"
)
filters = []
Expand Down
12 changes: 6 additions & 6 deletions src/fides/api/api/v1/endpoints/messaging_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def get_active_default_config(*, db: Session = Depends(deps.get_db)) -> Messagin
"""
Retrieves the active default messaging config.
"""
logger.info("Finding active default messaging config")
logger.debug("Finding active default messaging config")
try:
messaging_config = MessagingConfig.get_active_default(db)
except ValueError:
Expand Down Expand Up @@ -421,7 +421,7 @@ def get_configs(
"""
Retrieves configs for messaging.
"""
logger.info(
logger.debug(
"Finding all messaging configurations with pagination params {}", params
)
return paginate(
Expand All @@ -441,7 +441,7 @@ def get_config_by_key(
"""
Retrieves configs for messaging service by key.
"""
logger.info("Finding messaging config with key '{}'", config_key)
logger.debug("Finding messaging config with key '{}'", config_key)

try:
return get_messaging_config_by_key(db=db, key=config_key)
Expand All @@ -463,7 +463,7 @@ def get_default_config_by_type(
"""
Retrieves default config for messaging service by type.
"""
logger.info("Finding default messaging config of type '{}'", service_type)
logger.debug("Finding default messaging config of type '{}'", service_type)

messaging_config = MessagingConfig.get_by_type(db, service_type)
if not messaging_config:
Expand Down Expand Up @@ -620,7 +620,7 @@ def get_default_messaging_template(
"""
Retrieves default messaging template by template type.
"""
logger.info(
logger.debug(
"Finding default messaging template of template type '{}'", template_type
)
try:
Expand All @@ -645,7 +645,7 @@ def get_messaging_template_by_id(
"""
Retrieves messaging template by template tid.
"""
logger.info("Finding messaging template with id '{}'", template_id)
logger.debug("Finding messaging template with id '{}'", template_id)

try:
messaging_template = get_template_by_id(db, template_id)
Expand Down
12 changes: 6 additions & 6 deletions src/fides/api/api/v1/endpoints/policy_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def get_policy_list(
"""
Return a paginated list of all Policy records in this system
"""
logger.info("Finding all policies with pagination params '{}'", params)
logger.debug("Finding all policies with pagination params '{}'", params)
policies = Policy.query(db=db).order_by(Policy.created_at.desc())
return paginate(policies, params=params)


def get_policy_or_error(db: Session, policy_key: FidesKey) -> Policy:
"""Helper method to load Policy or throw a 404"""
logger.info("Finding policy with key '{}'", policy_key)
logger.debug("Finding policy with key '{}'", policy_key)
policy = Policy.get_by(db=db, field="key", value=policy_key)
if not policy:
raise HTTPException(
Expand Down Expand Up @@ -160,7 +160,7 @@ def get_rule_or_error(db: Session, policy_key: FidesKey, rule_key: FidesKey) ->
Also throws a 404 if a `Policy` with the given key can't be found.
"""
policy = get_policy_or_error(db, policy_key)
logger.info("Finding rule with key '{}'", rule_key)
logger.debug("Finding rule with key '{}'", rule_key)
rule = Rule.filter(
db=db,
conditions=((Rule.policy_id == policy.id) & (Rule.key == rule_key)),
Expand Down Expand Up @@ -191,7 +191,7 @@ def get_rule_list(
Throws a 404 if the given `Policy` can't be found.
"""
policy = get_policy_or_error(db, policy_key)
logger.info(
logger.debug(
"Finding all rules for policy {} with pagination params '{}'",
policy_key,
params,
Expand Down Expand Up @@ -382,7 +382,7 @@ def get_rule_target_or_error(
Helper method to load Rule Target or throw a 404.
Also throws a 404 if a `Policy` or `Rule` with the given keys can't be found.
"""
logger.info("Finding rule target with key '{}'", rule_target_key)
logger.debug("Finding rule target with key '{}'", rule_target_key)
rule: Rule = get_rule_or_error(db, policy_key, rule_key)
rule_target = RuleTarget.filter(
db=db,
Expand Down Expand Up @@ -417,7 +417,7 @@ def get_rule_target_list(
Throws a 404 if the given `Rule` or `Policy` can't be found.
"""
rule = get_rule_or_error(db, policy_key, rule_key)
logger.info(
logger.debug(
"Finding all rule targets for rule {} with pagination params '{}'",
rule_key,
params,
Expand Down
6 changes: 3 additions & 3 deletions src/fides/api/api/v1/endpoints/policy_webhook_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_policy_pre_execution_webhooks(
"""
policy = get_policy_or_error(db, policy_key)

logger.info(
logger.debug(
"Finding all Pre-Execution Webhooks for Policy '{}' with pagination params '{}'",
policy.key,
params,
Expand All @@ -76,7 +76,7 @@ def get_policy_post_execution_webhooks(
"""
policy = get_policy_or_error(db, policy_key)

logger.info(
logger.debug(
"Finding all Post-Execution Webhooks for Policy '{}' with pagination params '{}'",
policy.key,
params,
Expand Down Expand Up @@ -218,7 +218,7 @@ def get_policy_webhook_or_error(
Also verifies that the webhook belongs to the given Policy.
"""
logger.info(
logger.debug(
"Finding {}-Execution Webhook with key '{}' for Policy '{}'",
webhook_cls.prefix.capitalize(),
webhook_key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def get_pre_approval_webhook_list(
"""
Return a paginated list of all PreApprovalWebhook records in this system
"""
logger.info("Finding all pre_approval webhooks with pagination params '{}'", params)
logger.debug(
"Finding all pre_approval webhooks with pagination params '{}'", params
)
pre_approval_webhooks = PreApprovalWebhook.query(db=db).order_by(
PreApprovalWebhook.created_at.desc()
)
Expand All @@ -50,7 +52,7 @@ def get_pre_approval_webhook_or_error(
db: Session, webhook_key: FidesKey
) -> PreApprovalWebhook:
"""Helper method to load PreApprovalWebhook or throw a 404"""
logger.info("Finding PreApprovalWebhook with key '{}'", webhook_key)
logger.debug("Finding PreApprovalWebhook with key '{}'", webhook_key)
pre_approval_webhook = PreApprovalWebhook.get_by(
db=db, field="key", value=webhook_key
)
Expand Down
8 changes: 4 additions & 4 deletions src/fides/api/api/v1/endpoints/privacy_request_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def get_privacy_request_or_error(
db: Session, privacy_request_id: str, error_if_deleted: Optional[bool] = True
) -> PrivacyRequest:
"""Load the privacy request or throw a 404"""
logger.info("Finding privacy request with id '{}'", privacy_request_id)
logger.debug("Finding privacy request with id '{}'", privacy_request_id)

privacy_request = PrivacyRequest.get(db, object_id=privacy_request_id)

Expand Down Expand Up @@ -708,7 +708,7 @@ def _shared_privacy_request_search(
POST version of the endpoint.
"""

logger.info("Finding all request statuses with pagination params {}", params)
logger.debug("Finding all request statuses with pagination params {}", params)

query = db.query(PrivacyRequest)
query = _filter_privacy_request_queryset(
Expand All @@ -734,7 +734,7 @@ def _shared_privacy_request_search(
include_deleted_requests,
)

logger.info(
logger.debug(
"Sorting requests by field: {} and direction: {}", sort_field, sort_direction
)
query = _sort_privacy_request_queryset(query, sort_field, sort_direction)
Expand Down Expand Up @@ -921,7 +921,7 @@ def get_request_status_logs(

get_privacy_request_or_error(db, privacy_request_id, error_if_deleted=False)

logger.info(
logger.debug(
"Finding all execution logs for privacy request {} with params '{}'",
privacy_request_id,
params,
Expand Down
10 changes: 5 additions & 5 deletions src/fides/api/api/v1/endpoints/storage_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def get_configs(
"""
Retrieves configs for storage.
"""
logger.info("Finding all storage configurations with pagination params {}", params)
logger.debug("Finding all storage configurations with pagination params {}", params)
return paginate(
StorageConfig.query(db).order_by(StorageConfig.created_at.desc()), params=params
)
Expand All @@ -269,7 +269,7 @@ def get_config_by_key(
"""
Retrieves configs for storage by key.
"""
logger.info("Finding storage config with key '{}'", config_key)
logger.debug("Finding storage config with key '{}'", config_key)

storage_config = StorageConfig.get_by(db, field="key", value=config_key)
if not storage_config:
Expand Down Expand Up @@ -324,7 +324,7 @@ def get_active_default_config(
"""
Retrieves the active default storage config.
"""
logger.info("Finding active default storage config")
logger.debug("Finding active default storage config")
storage_config = get_active_default_storage_config(db)
if not storage_config:
raise HTTPException(
Expand Down Expand Up @@ -568,7 +568,7 @@ def get_default_configs(
"""
Retrieves default configs for each storage types.
"""
logger.info(
logger.debug(
"Finding default storage configurations with pagination params {}", params
)
return paginate(
Expand All @@ -590,7 +590,7 @@ def get_default_config_by_type(
"""
Retrieves default config for given storage type.
"""
logger.info("Finding default config for storage type '{}'", storage_type.value)
logger.debug("Finding default config for storage type '{}'", storage_type.value)
storage_config = get_default_storage_config_by_type(db, storage_type)
if not storage_config:
raise HTTPException(
Expand Down
4 changes: 2 additions & 2 deletions src/fides/api/api/v1/endpoints/user_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def get_user(*, db: Session = Depends(get_db), user_id: str) -> FidesUser:
if user is None:
raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="User not found")

logger.info("Returning user with id: '{}'.", user_id)
logger.debug("Returning user with id: '{}'.", user_id)
return user


Expand All @@ -529,7 +529,7 @@ def get_users(
if username:
query = query.filter(FidesUser.username.ilike(f"%{escape_like(username)}%"))

logger.info("Returning a paginated list of users.")
logger.debug("Returning a paginated list of users.")

return paginate(query.order_by(FidesUser.created_at.desc()), params=params)

Expand Down

0 comments on commit 22c05f2

Please sign in to comment.