Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] aio.api.github: Logging cleanups #167

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions aio.api.github/aio/api/github/abstract/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import abc
import logging
from functools import cached_property
from typing import Any, Type

Expand All @@ -18,6 +19,9 @@
from .tag import AGithubTag


logger = logging.getLogger(__name__)


class AGithubAPI(metaclass=abstracts.Abstraction):
"""Github API wrapper.

Expand Down Expand Up @@ -100,22 +104,30 @@ def tag_class(self) -> Type[AGithubTag]:

async def getitem(self, *args, **kwargs) -> Any:
"""Call the `gidgethub.getitem` api."""
# print("GETITEM", args, kwargs)
la = "\n".join(f" {arg}" for arg in args)
kwa = "\n".join(f" {k}: {v}" for k, v in kwargs.items())
logger.debug(f"GETITEM:\n{la}\n{kwa}".strip())
return await self.api.getitem(*args, **kwargs)

def getiter(self, *args, **kwargs) -> AGithubIterator:
"""Return a `GithubIterator` wrapping `gidgethub.getiter`."""
# print("GETITER", args, kwargs)
la = "\n".join(f" {arg}" for arg in args)
kwa = "\n".join(f" {k}: {v}" for k, v in kwargs.items())
logger.debug(f"GETITER:\n{la}\n{kwa}".strip())
return self.iterator_class(self.api, *args, **kwargs)

async def patch(self, *args, **kwargs):
"""Call the `gidgethub.patch` api."""
# print("PATCH", args, kwargs)
la = "\n".join(f" {arg}" for arg in args)
kwa = "\n".join(f" {k}: {v}" for k, v in kwargs.items())
logger.debug(f"PATCH:\n{la}\n{kwa}".strip())
return await self.api.patch(*args, **kwargs)

async def post(self, *args, **kwargs):
"""Call the `gidgethub.post` api."""
# print("POST", args, kwargs)
la = "\n".join(f" {arg}" for arg in args)
kwa = "\n".join(f" {k}: {v}" for k, v in kwargs.items())
logger.debug(f"POST:\n{la}\n{kwa}".strip())
return await self.api.post(*args, **kwargs)

def repo_from_url(self, url):
Expand Down