Skip to content

Commit

Permalink
Add logger line for loop running
Browse files Browse the repository at this point in the history
  • Loading branch information
4Kaylum committed Sep 11, 2023
1 parent 470d632 commit 79a775a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion novus/ext/client/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
)


log = logging.getLogger("novus.ext.bot.command")
log = logging.getLogger("novus.ext.client.command")


class Autocomplete:
Expand Down
6 changes: 5 additions & 1 deletion novus/ext/client/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import asyncio
import functools
import logging
from enum import Enum, auto
from typing import TYPE_CHECKING, Any, Callable, Coroutine

Expand All @@ -31,6 +32,8 @@
'Loop',
)

log = logging.getLogger("novus.ext.client.loop")


class LoopBehavior(Enum):
"""
Expand Down Expand Up @@ -150,7 +153,7 @@ def start(self) -> None:

if self.task is not None:
raise RuntimeError("Loop is already running!")
self.bg_task = asyncio.create_task(self._run(), name=f"Loop task in {self.func.__name__}")
self.bg_task = asyncio.create_task(self._run(), name=f"Looping task in {self.func.__name__}")

async def _run(self) -> None:
if self.wait_until_ready:
Expand All @@ -162,6 +165,7 @@ async def _run(self) -> None:
await asyncio.sleep(self.loop_time)
except asyncio.CancelledError:
return
log.info("Running task in loop %s", self.func.__name__)
task = asyncio.create_task(self.func())
if self.end_behavior == LoopBehavior.end:
await asyncio.wait([task])
Expand Down
2 changes: 1 addition & 1 deletion novus/ext/client/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
)


log = logging.getLogger("novus.ext.bot.plugin")
log = logging.getLogger("novus.ext.client.plugin")


class PluginMeta(type):
Expand Down

0 comments on commit 79a775a

Please sign in to comment.