From 22c05f2f32bd691c20421dbb176e33fed7462ea9 Mon Sep 17 00:00:00 2001 From: Robert Keyser <39230492+RobertKeyser@users.noreply.github.com> Date: Mon, 6 Jan 2025 14:08:02 -0600 Subject: [PATCH] Modify Logging Levels for Read-only actions (#5647) --- src/fides/api/api/v1/endpoints/dataset_endpoints.py | 12 ++++++------ .../api/api/v1/endpoints/messaging_endpoints.py | 12 ++++++------ src/fides/api/api/v1/endpoints/policy_endpoints.py | 12 ++++++------ .../api/api/v1/endpoints/policy_webhook_endpoints.py | 6 +++--- .../v1/endpoints/pre_approval_webhook_endpoints.py | 6 ++++-- .../api/v1/endpoints/privacy_request_endpoints.py | 8 ++++---- src/fides/api/api/v1/endpoints/storage_endpoints.py | 10 +++++----- src/fides/api/api/v1/endpoints/user_endpoints.py | 4 ++-- 8 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/fides/api/api/v1/endpoints/dataset_endpoints.py b/src/fides/api/api/v1/endpoints/dataset_endpoints.py index 9240396295..cf443ed062 100644 --- a/src/fides/api/api/v1/endpoints/dataset_endpoints.py +++ b/src/fides/api/api/v1/endpoints/dataset_endpoints.py @@ -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( @@ -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, @@ -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( @@ -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, @@ -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, @@ -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 = [] diff --git a/src/fides/api/api/v1/endpoints/messaging_endpoints.py b/src/fides/api/api/v1/endpoints/messaging_endpoints.py index 64ffc0097c..55c89a088a 100644 --- a/src/fides/api/api/v1/endpoints/messaging_endpoints.py +++ b/src/fides/api/api/v1/endpoints/messaging_endpoints.py @@ -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: @@ -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( @@ -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) @@ -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: @@ -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: @@ -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) diff --git a/src/fides/api/api/v1/endpoints/policy_endpoints.py b/src/fides/api/api/v1/endpoints/policy_endpoints.py index 5e9a66483b..b0870e912b 100644 --- a/src/fides/api/api/v1/endpoints/policy_endpoints.py +++ b/src/fides/api/api/v1/endpoints/policy_endpoints.py @@ -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( @@ -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)), @@ -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, @@ -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, @@ -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, diff --git a/src/fides/api/api/v1/endpoints/policy_webhook_endpoints.py b/src/fides/api/api/v1/endpoints/policy_webhook_endpoints.py index f1e5bc35f5..7b3c9715cc 100644 --- a/src/fides/api/api/v1/endpoints/policy_webhook_endpoints.py +++ b/src/fides/api/api/v1/endpoints/policy_webhook_endpoints.py @@ -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, @@ -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, @@ -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, diff --git a/src/fides/api/api/v1/endpoints/pre_approval_webhook_endpoints.py b/src/fides/api/api/v1/endpoints/pre_approval_webhook_endpoints.py index 81d53b6a4d..88ab7f30b6 100644 --- a/src/fides/api/api/v1/endpoints/pre_approval_webhook_endpoints.py +++ b/src/fides/api/api/v1/endpoints/pre_approval_webhook_endpoints.py @@ -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() ) @@ -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 ) diff --git a/src/fides/api/api/v1/endpoints/privacy_request_endpoints.py b/src/fides/api/api/v1/endpoints/privacy_request_endpoints.py index 3bec34ffed..bfe42a1455 100644 --- a/src/fides/api/api/v1/endpoints/privacy_request_endpoints.py +++ b/src/fides/api/api/v1/endpoints/privacy_request_endpoints.py @@ -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) @@ -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( @@ -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) @@ -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, diff --git a/src/fides/api/api/v1/endpoints/storage_endpoints.py b/src/fides/api/api/v1/endpoints/storage_endpoints.py index e4916e4e1c..58c82340b3 100644 --- a/src/fides/api/api/v1/endpoints/storage_endpoints.py +++ b/src/fides/api/api/v1/endpoints/storage_endpoints.py @@ -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 ) @@ -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: @@ -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( @@ -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( @@ -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( diff --git a/src/fides/api/api/v1/endpoints/user_endpoints.py b/src/fides/api/api/v1/endpoints/user_endpoints.py index ab6b491a42..aeb9e674e4 100644 --- a/src/fides/api/api/v1/endpoints/user_endpoints.py +++ b/src/fides/api/api/v1/endpoints/user_endpoints.py @@ -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 @@ -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)