fix(bible): added more verbose debug logging
This commit is contained in:
parent
fb2e607af1
commit
f3db29beef
1 changed files with 17 additions and 8 deletions
|
@ -5,6 +5,7 @@
|
||||||
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
|
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
|
||||||
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
|
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
|
||||||
|
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
@ -63,8 +64,11 @@ class Bible(commands.Cog):
|
||||||
}
|
}
|
||||||
|
|
||||||
async with self.session.get(url, headers=headers, params=params) as response:
|
async with self.session.get(url, headers=headers, params=params) as response:
|
||||||
|
data = await response.json()
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"_get_passage executed with a response code of: %s", response.status
|
"_get_passage executed with a response code of: %s\n%s",
|
||||||
|
response.status,
|
||||||
|
json.dumps(data),
|
||||||
)
|
)
|
||||||
if response.status == 401:
|
if response.status == 401:
|
||||||
raise bible.errors.Unauthorized()
|
raise bible.errors.Unauthorized()
|
||||||
|
@ -72,7 +76,6 @@ class Bible(commands.Cog):
|
||||||
raise bible.errors.BibleAccessError()
|
raise bible.errors.BibleAccessError()
|
||||||
if response.status == 404:
|
if response.status == 404:
|
||||||
raise bible.errors.NotFound()
|
raise bible.errors.NotFound()
|
||||||
data = await response.json()
|
|
||||||
return data["data"]
|
return data["data"]
|
||||||
|
|
||||||
async def _get_books(self, bible_id: str) -> dict:
|
async def _get_books(self, bible_id: str) -> dict:
|
||||||
|
@ -81,14 +84,16 @@ class Bible(commands.Cog):
|
||||||
headers = await self.bot.get_shared_api_tokens("api.bible")
|
headers = await self.bot.get_shared_api_tokens("api.bible")
|
||||||
|
|
||||||
async with self.session.get(url, headers=headers) as response:
|
async with self.session.get(url, headers=headers) as response:
|
||||||
|
data = await response.json()
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"_get_books executed with a response code of: %s", response.status
|
"_get_books executed with a response code of: %s\n%s",
|
||||||
|
response.status,
|
||||||
|
json.dumps(data),
|
||||||
)
|
)
|
||||||
if response.status == 401:
|
if response.status == 401:
|
||||||
raise bible.errors.Unauthorized()
|
raise bible.errors.Unauthorized()
|
||||||
if response.status == 403:
|
if response.status == 403:
|
||||||
raise bible.errors.BibleAccessError()
|
raise bible.errors.BibleAccessError()
|
||||||
data = await response.json()
|
|
||||||
return data["data"]
|
return data["data"]
|
||||||
|
|
||||||
async def _get_chapters(self, bible_id: str, book_id: str) -> dict:
|
async def _get_chapters(self, bible_id: str, book_id: str) -> dict:
|
||||||
|
@ -97,14 +102,16 @@ class Bible(commands.Cog):
|
||||||
headers = await self.bot.get_shared_api_tokens("api.bible")
|
headers = await self.bot.get_shared_api_tokens("api.bible")
|
||||||
|
|
||||||
async with self.session.get(url, headers=headers) as response:
|
async with self.session.get(url, headers=headers) as response:
|
||||||
|
data = await response.json()
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"_get_chapters executed with a response code of: %s", response.status
|
"_get_chapters executed with a response code of: %s\n%s",
|
||||||
|
response.status,
|
||||||
|
json.dumps(data),
|
||||||
)
|
)
|
||||||
if response.status == 401:
|
if response.status == 401:
|
||||||
raise bible.errors.Unauthorized()
|
raise bible.errors.Unauthorized()
|
||||||
if response.status == 403:
|
if response.status == 403:
|
||||||
raise bible.errors.BibleAccessError()
|
raise bible.errors.BibleAccessError()
|
||||||
data = await response.json()
|
|
||||||
return data["data"]
|
return data["data"]
|
||||||
|
|
||||||
async def _get_verses(self, bible_id: str, book_id: str, chapter: int) -> dict:
|
async def _get_verses(self, bible_id: str, book_id: str, chapter: int) -> dict:
|
||||||
|
@ -113,14 +120,16 @@ class Bible(commands.Cog):
|
||||||
headers = await self.bot.get_shared_api_tokens("api.bible")
|
headers = await self.bot.get_shared_api_tokens("api.bible")
|
||||||
|
|
||||||
async with self.session.get(url, headers=headers) as response:
|
async with self.session.get(url, headers=headers) as response:
|
||||||
|
data = await response.json()
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"_get_verses executed with a response code of: %s", response.status
|
"_get_verses executed with a response code of: %s\n%s",
|
||||||
|
response.status,
|
||||||
|
json.dumps(data),
|
||||||
)
|
)
|
||||||
if response.status == 401:
|
if response.status == 401:
|
||||||
raise bible.errors.Unauthorized()
|
raise bible.errors.Unauthorized()
|
||||||
if response.status == 403:
|
if response.status == 403:
|
||||||
raise bible.errors.BibleAccessError()
|
raise bible.errors.BibleAccessError()
|
||||||
data = await response.json()
|
|
||||||
return data["data"]
|
return data["data"]
|
||||||
|
|
||||||
@commands.group(autohelp=True)
|
@commands.group(autohelp=True)
|
||||||
|
|
Loading…
Reference in a new issue