summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-10-20 21:48:33 -0700
committerFuwn <[email protected]>2025-10-20 21:48:33 -0700
commitaaef2ffebe106e30612c70bb86a2f8447968ce15 (patch)
treedb529fa00fd66ffda24814f1539238a3e7ca91a8
parentfeat(gateway:messageCreate): Add dmForwarder (diff)
downloadumabotdiscord-aaef2ffebe106e30612c70bb86a2f8447968ce15.tar.xz
umabotdiscord-aaef2ffebe106e30612c70bb86a2f8447968ce15.zip
feat(shared): Add logging framework
-rw-r--r--packages/gateway/src/listeners/clientReady/voiceConnection.ts1
-rw-r--r--packages/shared/log.ts29
-rw-r--r--tsconfig.json3
3 files changed, 32 insertions, 1 deletions
diff --git a/packages/gateway/src/listeners/clientReady/voiceConnection.ts b/packages/gateway/src/listeners/clientReady/voiceConnection.ts
index 87101d8..3665536 100644
--- a/packages/gateway/src/listeners/clientReady/voiceConnection.ts
+++ b/packages/gateway/src/listeners/clientReady/voiceConnection.ts
@@ -28,6 +28,7 @@ const createVoiceConnection = (
console.error(
`Voice channel ${channelId} not found or is not a voice channel for guild ${guildId}`,
);
+
return;
}
diff --git a/packages/shared/log.ts b/packages/shared/log.ts
new file mode 100644
index 0000000..35a3590
--- /dev/null
+++ b/packages/shared/log.ts
@@ -0,0 +1,29 @@
+/* eslint-disable no-unused-vars */
+
+export enum LogLevel {
+ Error = "ERROR",
+ Warning = "WARNING",
+ Info = "INFO",
+ Debug = "DEBUG",
+ Trace = "TRACE",
+}
+
+export const log = (
+ unit: string,
+ message: string,
+ level: LogLevel = LogLevel.Info,
+) => {
+ const timestamp = new Date().toISOString();
+ const levelColors = {
+ [LogLevel.Error]: "\x1b[31m",
+ [LogLevel.Warning]: "\x1b[33m",
+ [LogLevel.Info]: "\x1b[32m",
+ [LogLevel.Debug]: "\x1b[34m",
+ [LogLevel.Trace]: "\x1b[35m",
+ };
+ const levelColor = levelColors[level];
+
+ console.log(
+ `\x1b[37m${timestamp}\x1b[0m ${levelColor}${level}\x1b[0m \x1b[1m${unit}\x1b[22m \x1b[37m> ${message}\x1b[0m`,
+ );
+};
diff --git a/tsconfig.json b/tsconfig.json
index b0ed945..7198a2e 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -21,7 +21,8 @@
}
},
"include": [
- "packages/interactions/**/*"
+ "packages/interactions/**/*",
+ "packages/shared/**/*"
],
"exclude": [
"node_modules",