more logging & remove unused code
All checks were successful
Build and Push Docker Image / build (push) Successful in 11s
All checks were successful
Build and Push Docker Image / build (push) Successful in 11s
This commit is contained in:
parent
e6ddf290ca
commit
26fe8ca523
@ -32,45 +32,18 @@ class ConsoleCog(commands.Cog):
|
||||
|
||||
@tasks.loop(seconds=3)
|
||||
async def listen_for_changes(self):
|
||||
log.debug("listening for changes")
|
||||
try:
|
||||
file_reader = LogFileReader(CONSOLE_FILE_PATH)
|
||||
except FileNotFoundError:
|
||||
log.error("console file not found")
|
||||
self.listen_for_changes.cancel()
|
||||
return
|
||||
|
||||
log.debug("checking over changes")
|
||||
async for line in file_reader.read():
|
||||
await self.process_console_line(line)
|
||||
|
||||
# @tasks.loop(seconds=1)
|
||||
# async def monitor_console(self):
|
||||
# """
|
||||
# Check the latest version of the console log file.
|
||||
# """
|
||||
|
||||
# if not CONSOLE_FILE_PATH.exists():
|
||||
# self.monitor_console.cancel()
|
||||
# raise FileNotFoundError("Server console file doesn't exist, task cancelled.")
|
||||
|
||||
# async with aiofiles.open(CONSOLE_FILE_PATH, "r", encoding="utf-8") as file:
|
||||
|
||||
# # If we are at 0, restarting the bot would cause rapid fire of all log lines,
|
||||
# # instead lets grab the latest line, to prevent spam.
|
||||
# if self._last_line_number == 0:
|
||||
# await file.seek(0, 2)
|
||||
# self._last_line_number = await file.tell()
|
||||
# return
|
||||
|
||||
# await file.seek(self._last_line_number)
|
||||
# lines = await file.readlines()
|
||||
# if not lines:
|
||||
# log.debug("no new lines to read")
|
||||
# return
|
||||
|
||||
# for line in lines:
|
||||
# await self.process_console_line(line.strip())
|
||||
|
||||
# self._last_line_number = await file.tell()
|
||||
|
||||
async def process_console_line(self, line: str):
|
||||
"""
|
||||
Determine how to handle the given line from the server console.
|
||||
|
@ -19,7 +19,7 @@ class LogFileReader:
|
||||
|
||||
self.file_path = file_path
|
||||
self._last_line_number = 0
|
||||
|
||||
log.debug("%s created with path %s", self.__class__.__name__, str(file_path))
|
||||
|
||||
async def read(self):
|
||||
if not self.file_path.exists():
|
||||
|
Reference in New Issue
Block a user