@arkyn/server 2.0.1-beta.2 → 2.0.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "2.0.1-beta.2",
3
+ "version": "2.0.1-beta.4",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./src/index.ts",
6
6
  "type": "module",
@@ -7,10 +7,35 @@ function httpDebug(name: string, body: any, cause?: any) {
7
7
  const reset = "\x1b[0m";
8
8
  const cyan = "\x1b[36m";
9
9
 
10
- const pathname = new URL(import.meta.url).pathname;
11
- console.log(`${cyan}[ARKYN-DEBUG]${reset} ${name} initialized`);
12
- console.log(`${cyan}[ARKYN-DEBUG]${reset} Pathname:`, pathname);
13
- console.log(`${cyan}[ARKYN-DEBUG]${reset} Body:`, body);
10
+ const debugName = `${cyan}[ARKYN-DEBUG]${reset}`;
11
+
12
+ const error = new Error();
13
+ const stackLines =
14
+ error.stack?.split("\n").map((line) => line.trim()) || [];
15
+
16
+ let callerInfo = "Unknown caller";
17
+ let functionName = "Unknown function";
18
+
19
+ for (const line of stackLines) {
20
+ if (
21
+ !line.includes("httpDebug") &&
22
+ !line.includes("BadGateway") &&
23
+ !line.includes("BadRequest")
24
+ ) {
25
+ // Captura formatos diferentes de stack trace
26
+ const match = line.match(/at (.+?) \((.+?)\)/) || line.match(/at (.+)/);
27
+ if (match) {
28
+ functionName = match[1].split(" ")[0]; // Pega apenas o nome da função
29
+ callerInfo = match[2] || match[1]; // Caminho do arquivo e linha
30
+ break;
31
+ }
32
+ }
33
+ }
34
+
35
+ console.log(`${debugName} ${name} initialized`);
36
+ console.log(`${debugName} Caller Function: ${functionName}`);
37
+ console.log(`${debugName} Caller Location: ${callerInfo}`);
38
+ console.log(`${debugName} Body:`, body);
14
39
  if (cause) console.log(`[ARKYN-DEBUG] Cause:`, cause);
15
40
  }
16
41
  }