Skip to content

Commit 666c3f6

Browse files
Refactor: Set default logging verbosity to WARNING
Changes the default `absl.logging` verbosity level from INFO to WARNING. This reduces the amount of log output during normal operation, as INFO-level messages detailing each API call page fetch will no longer be displayed by default. WARNING and ERROR level logs will still be shown. Users needing to debug API calls can temporarily change the verbosity level back to INFO in the script.
1 parent 1ac8385 commit 666c3f6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

scripts/gha/get_pr_review_comments_standalone.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
BASE_URL = 'https://api.github.com' # Base URL for GitHub API
4444
GITHUB_API_URL = '' # Dynamically constructed API URL for the specific repository
4545

46-
logging.set_verbosity(logging.INFO)
46+
logging.set_verbosity(logging.WARNING)
4747

4848

4949
def set_repo_url_standalone(owner_name, repo_name):
@@ -105,7 +105,7 @@ def get_pull_request_review_comments(token, pull_number, since=None):
105105

106106
except requests.exceptions.RequestException as e:
107107
logging.error(f"Error fetching review comments (page {page}, params: {current_page_params}) for PR {pull_number}: {e}")
108-
break
108+
return None # Indicate error
109109
return results
110110

111111

@@ -136,7 +136,7 @@ def list_pull_requests(token, state, head, base):
136136
keep_going = (len(current_page_results) == per_page)
137137
except requests.exceptions.RequestException as e:
138138
logging.error(f"Error listing pull requests (page {params.get('page', 'N/A')}, params: {params}) for {OWNER}/{REPO}: {e}")
139-
break
139+
return None # Indicate error
140140
return results
141141

142142

@@ -354,9 +354,12 @@ def parse_repo_url(url_string):
354354
since=args.since
355355
)
356356

357-
if not comments:
358-
sys.stderr.write(f"No review comments found for PR #{pull_request_number} (or matching filters), or an error occurred.\n")
359-
return
357+
if comments is None: # Explicit check for None, indicating an API/network error
358+
sys.stderr.write(f"Error: Failed to fetch review comments due to an API or network issue.{error_suffix}\nPlease check logs for details.\n")
359+
sys.exit(1)
360+
elif not comments: # Empty list, meaning no comments found or matching filters
361+
sys.stderr.write(f"No review comments found for PR #{pull_request_number} (or matching filters).\n")
362+
return # Graceful exit with 0
360363

361364
latest_activity_timestamp_obj = None
362365
processed_comments_count = 0

0 commit comments

Comments
 (0)