This commit is contained in:
artie 2025-01-01 16:14:23 +01:00
parent 57281a976d
commit 492cf7c384
4 changed files with 1 additions and 38 deletions

1
.gitignore vendored
View File

@ -1,7 +1,6 @@
__pycache__/
temp/
env/
*.log
config.prod.toml
config.dev.toml
status.json

View File

@ -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)

View File

@ -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."""

View File

@ -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",