Commit 64910b66 authored by Blaise Thompson's avatar Blaise Thompson
Browse files

Merge branch 'yep106' into 'master'

YEP-106: update logging calls

See merge request !8
parents 747aba79 448bb2d9
Pipeline #146596394 passed with stages
in 2 minutes and 32 seconds
......@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
### Changed
- from now on, yaqd-gdrive will use calendar based versioning
- cleanup repository
- Use daemon level loggers, see [YEP-106](https://yeps.yaq.fyi/106)
## [0.2.0]
......
......@@ -14,8 +14,6 @@ import aiohttp.web # type: ignore
import appdirs # type: ignore
import yaqd_core
logger = yaqd_core.logging.getLogger(__name__)
logger.setLevel(yaqd_core.logging.INFO)
UploadItem = collections.namedtuple(
"UploadItem", "kind name path parent client_id", defaults=[None]
......@@ -121,14 +119,14 @@ class GDrive(yaqd_core.Base):
"grant_type": "authorization_code",
},
) as res:
logger.debug(await res.text())
self.logger.debug(await res.text())
res.raise_for_status()
json = await res.json()
self._access_token = json["access_token"]
self._refresh_token = json["refresh_token"]
async def _use_refresh_token(self):
logger.info("Refreshing token")
self.logger.info("Refreshing token")
async with self._http_session.post(
self._token_url,
json={
......@@ -160,7 +158,7 @@ class GDrive(yaqd_core.Base):
params={"uploadType": "multipart"},
data=mpwriter,
) as res:
logger.debug(await res.text())
self.logger.debug(await res.text())
return res
async def _create_folder(self, name, parent, *, id_=None):
......@@ -180,7 +178,7 @@ class GDrive(yaqd_core.Base):
params={"uploadType": "multipart"},
data=mpwriter,
) as res:
logger.debug(await res.text())
self.logger.debug(await res.text())
return res
@refresh_oauth
......@@ -243,7 +241,7 @@ class GDrive(yaqd_core.Base):
async def _upload(self):
while True:
logger.debug("_upload", len(self._upload_queue))
self.logger.debug("_upload", len(self._upload_queue))
while self._upload_queue:
self._busy = True
try:
......@@ -260,7 +258,7 @@ class GDrive(yaqd_core.Base):
except FileNotFoundError:
self._upload_queue.pop(0)
except BaseException as e:
logger.error(e)
self.logger.error(e)
self._upload_queue.append(self._upload_queue.pop(0))
else:
try:
......@@ -299,7 +297,7 @@ class GDrive(yaqd_core.Base):
else:
self._upload_queue.append(UploadItem(**item))
except BaseException as e:
logger.error(e)
self.logger.error(e)
self._copy_queue.append(self._copy_queue.pop(0))
else:
self._copy_queue.pop(0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment