Skip to content

Commit

Permalink
use rich log handler
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s committed Sep 3, 2023
1 parent 9bf06f5 commit 93cea92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions pip_abandoned/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

import requests
from rich.console import Console
from rich.logging import RichHandler
from rich.table import Table

if sys.version_info < (3, 10):
from importlib_metadata import Prepared, distributions
else:
from importlib.metadata import Prepared, distributions

logging.basicConfig(format="%(levelname)s: %(message)s")
logging.basicConfig(format="%(message)s", handlers=[RichHandler(show_time=False)])
logger = logging.getLogger(__name__)

console = Console()
Expand Down Expand Up @@ -83,7 +84,7 @@ def get_graphql_query(dist_urls):


def query_github_api(gh_token, query):
logger.info(f"Querying GitHub API: {query}")
logger.info(f"Querying GitHub API:\n{query}")

resp = requests.post(
"https://api.github.com/graphql",
Expand All @@ -92,11 +93,11 @@ def query_github_api(gh_token, query):
)
resp.raise_for_status()
body = resp.json()
logger.info(f"Response from GitHub API: {json.dumps(body, indent=2)}")
logger.info(f"Response from GitHub API:\n{json.dumps(body, indent=2)}")

if body.get("errors"):
logger.warning(
f"Encountered errors calling GitHub API: {json.dumps(body['errors'], indent=2)}"
f"Encountered errors calling GitHub API:\n{json.dumps(body['errors'], indent=2)}"
)

return body["data"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dynamic = ["version"]
requires-python = ">=3.8"
dependencies = [
"requests>=2,<3",
"rich>=1",
"rich>=10",
"importlib-metadata>=4.6; python_version < '3.10'",
]

Expand Down

0 comments on commit 93cea92

Please sign in to comment.