Skip to content

Commit

Permalink
refactor: 로깅 포맷 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
Jjungs7 committed Oct 29, 2023
1 parent a02aa8f commit 9da9887
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 46 deletions.
57 changes: 16 additions & 41 deletions deploy/prod.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
apiVersion: v1
kind: Namespace
metadata:
name: poolini
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: poolini-deployment
namespace: poolini
namespace: poolc
labels:
app.kubernetes.io/name: poolini
spec:
replicas: 3
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: poolini
Expand All @@ -20,46 +15,26 @@ spec:
labels:
app.kubernetes.io/name: poolini
spec:
imagePullSecrets:
- name: poolc-github-packages-secret
containers:
- name: poolini
image: poolini:1.14.2
ports:
- containerPort: 80
image: ghcr.io/poolc/poolini:latest
resources:
requests:
cpu: "200m"
memory: "64Mi"
limits:
cpu: "400m"
memory: "128Mi"
---
apiVersion: v1
kind: Service
metadata:
name: poolini-service
namespace: poolini
spec:
selector:
app.kubernetes.io/name: poolini
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: poolini-ingress
namespace: poolini
spec:
rules:
- host: "poolini.poolc.org"
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: poolini-service
port:
number: 80
env:
- name: DISCORD_TOKEN
valueFrom:
secretKeyRef:
name: poolc-poolini-secrets
key: DISCORD_TOKEN
- name: POOLC_API_ADMIN_TOKEN
valueFrom:
secretKeyRef:
name: poolc-poolini-secrets
key: POOLC_API_ADMIN_TOKEN
14 changes: 9 additions & 5 deletions poolini/discord_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@

@client.event
async def on_ready() -> None:
logger.info("Captain [%s] on duty!", client.user)
logger.info("[init] \"%s\" Captain on duty!", client.user)


@client.event
async def on_member_join(member: discord.Member) -> None:
active_members_role_id = 1168076737150734416
active_members_role = discord.utils.get(client.guilds[0].roles, id=active_members_role_id)

assert isinstance(active_members_role, discord.Role)
access_logger.info("[role] \"%s\" assigned role %s", active_members_role.name, member)

await member.add_roles(active_members_role) # type: ignore (pylance)


Expand All @@ -44,7 +48,7 @@ async def on_message(message) -> None:
sys.stdout = io.StringIO()

permissions = "user"
access_logger.info("[%s]: %s", message.author, message.content)
access_logger.info("[chat]: \"%s\" %s", message.author, message.content)
poolini = cli_static_factory(permissions)
args = message.content.split(" ")[1:]
try:
Expand All @@ -63,12 +67,12 @@ async def on_error(event, *args) -> None:
exc_type, exc_value, _ = sys.exc_info()
assert isinstance(exc_type, BaseException)

log_msg = f"{'.'.join([exc_type.__module__, exc_type.__name__])}: {exc_value}."
log_msg = f"[error/{'.'.join([exc_type.__module__, exc_type.__name__])}] {exc_value}."
if event == "on_message":
message = args[0]
log_msg += f" (Author: {message.author} / Message: {message.content})"
log_msg += f" \"{message.author}\" {message.content}"
else:
log_msg += f" (Msg: {args})"
log_msg += f" {args}"

logger.error(log_msg)

Expand Down

0 comments on commit 9da9887

Please sign in to comment.