From 492cf7c384a2c934474bc1d62e32a5945b8966cd Mon Sep 17 00:00:00 2001 From: artie Date: Wed, 1 Jan 2025 16:14:23 +0100 Subject: [PATCH] logging --- .gitignore | 1 - artemis/cogs/events.py | 10 +--------- artemis/cogs/owner.py | 25 ------------------------- ecosystem.config.js | 3 --- 4 files changed, 1 insertion(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index b1abe8d..060292f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ __pycache__/ temp/ env/ -*.log config.prod.toml config.dev.toml status.json \ No newline at end of file diff --git a/artemis/cogs/events.py b/artemis/cogs/events.py index 8a55ecb..d3d6b73 100644 --- a/artemis/cogs/events.py +++ b/artemis/cogs/events.py @@ -5,7 +5,6 @@ import contextlib import logging import random import re -from logging.handlers import RotatingFileHandler from typing import TYPE_CHECKING import discord @@ -18,13 +17,6 @@ if TYPE_CHECKING: from ..bot import Artemis log = logging.getLogger("artemis") -cmd_log = logging.getLogger("commands") -cmd_log.propagate = False -cmd_log.setLevel(logging.DEBUG) -ch = RotatingFileHandler("data/commands.log", "a", 10 * 1024**2, encoding="utf-8") -ch.setLevel(logging.DEBUG) -ch.setFormatter(logging.Formatter("[{asctime}] {message}", "%Y-%m-%d %H:%M:%S", style="{")) -cmd_log.addHandler(ch) TIKTOK_RE = re.compile( r"https://vm\.tiktok\.com/(\w+)|https://(?:www\.)?tiktok\.com/(@.+?/video/\d+)" @@ -93,7 +85,7 @@ class Events(commands.Cog): content = message.content.lower() if content.startswith(config.prefix) and f"{config.prefix}jsk" not in content: - cmd_log.debug(f"{message.author.id}: {message.content}") + log.info(f"[cmd] {message.author.id}: {message.content}") await self.handle_triggers(message, content) await self.handle_links(message, content) diff --git a/artemis/cogs/owner.py b/artemis/cogs/owner.py index f8748e8..1935713 100644 --- a/artemis/cogs/owner.py +++ b/artemis/cogs/owner.py @@ -180,31 +180,6 @@ except Exception: jsk_py = self.bot.get_command("jsk py") await jsk_py(ctx, argument=codeblocks.codeblock_converter(code)) - @dev.command() - async def logs( - self, ctx: commands.Context, app: Optional[str] = "bot", lines: Optional[int] = "50" - ): - """ - Displays logs for various apps. - Available: bot, cmds, api, nginx - - """ - match app: - case "bot": - args = f"tail -n {lines} artemis.log" - case "cmds": - args = f"tail -n {lines} data/commands.log" - case "api": - args = f"tail -n {lines} ../api/api.log" - case "nginx": - args = f"tail -n {lines} /var/log/nginx/access.log" - case _: - return await ctx.send("Unrecognized app.") - - ext = "py" if app == "bot" else "txt" - file = await utils.run_cmd_to_file(args, f"{app}-logs_{utils.time()}.{ext}") - return await ctx.reply(file=file) - @dev.command() async def http(self, ctx: commands.Context, url: str): """Debugs HTTP requests.""" diff --git a/ecosystem.config.js b/ecosystem.config.js index 3f0bac2..3eaf294 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -4,9 +4,6 @@ module.exports = { name: "artemis", script: "./env/bin/python", args: "-m artemis.bot", - out_file: "/dev/null", - error_file: "/dev/null", - log_file: "./artemis.log", time: true, env: { PYTHONUNBUFFERED: "1",