@remote-logger/sdk 0.1.3 → 0.1.5

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/SKILL.md CHANGED
@@ -22,10 +22,34 @@ You should default to placing logs early when investigating runtime issues. Don'
22
22
  - Correlating behavior across multiple services or processes (use `traceId`)
23
23
  - Monitoring a specific code path after a fix to verify it works
24
24
 
25
+ ## Best Practices
26
+
27
+ **Use `withGroup()` to categorize logs — don't embed context in the message.**
28
+
29
+ The `group` field is a queryable column in ClickHouse. When you prefix messages manually, you lose the ability to filter and aggregate by subsystem.
30
+
31
+ ```ts
32
+ // Bad — context is buried in the message string, not queryable
33
+ logger.info("[StorageService] Getting user");
34
+
35
+ // Good — group is a structured, queryable field
36
+ const log = logger.withGroup("StorageService");
37
+ log.info("Getting user");
38
+
39
+ // Also good — inline object form for one-off logs
40
+ logger.info({ message: "Getting user", group: "StorageService" });
41
+ ```
42
+
43
+ This lets you later query `WHERE group = 'StorageService'` or `GROUP BY group` to see log volume by subsystem.
44
+
45
+ When placing logs across multiple files or modules during an investigation, create a scoped logger per module so logs are naturally organized. Use `withTraceId()` to correlate logs across a single request or operation, especially across services.
46
+
25
47
  ## SDK Quick Reference
26
48
 
27
49
  ### Setup (already done if the project uses this SDK)
28
50
 
51
+ **Important:** Look for an existing logger instance in the project before creating a new one. Projects typically have a shared logger in a file like `logger.ts` or `lib/logger.ts` — import from there instead of calling `createLogger()` again.
52
+
29
53
  ```ts
30
54
  import { createLogger } from '@remote-logger/sdk';
31
55
 
@@ -49,15 +73,6 @@ logger.error(err as Error, { orderId: order.id }); // Error objects extract sta
49
73
  logger.fatal(new Error("database unreachable"));
50
74
  ```
51
75
 
52
- ### Scoped Loggers (for grouping or tracing)
53
-
54
- ```ts
55
- const authLogger = logger.withGroup("auth"); // all calls get group: "auth"
56
- const reqLogger = logger.withTraceId("req-abc"); // all calls get trace_id: "req-abc"
57
- ```
58
-
59
- Use `group` to categorize logs by subsystem (e.g., "auth", "billing", "renderer"). Use `traceId` to correlate logs across a single request or operation, especially across services.
60
-
61
76
  ### Console Interception
62
77
 
63
78
  ```ts
@@ -111,7 +126,7 @@ group String -- categorization (e.g., 'api/billing', 'main', 'rendere
111
126
  message String -- log content
112
127
  stack Nullable(String) -- stack trace
113
128
  error_type String -- exception class name
114
- metadata Map(String, String) -- arbitrary key-value pairs
129
+ metadata JSON -- arbitrary structured data
115
130
  ```
116
131
 
117
132
  ## Do NOT
package/dist/index.js CHANGED
@@ -346,7 +346,7 @@ var LEVEL_ORDER = {
346
346
  ERROR: 3,
347
347
  FATAL: 4
348
348
  };
349
- var SDK_VERSION = "0.1.3";
349
+ var SDK_VERSION = "0.1.4";
350
350
  var DEFAULT_BASE_URL = "https://log.terodato.com";
351
351
  var BATCH_SIZE = 50;
352
352
  var MAX_BUFFER_SIZE = 1e3;
@@ -607,7 +607,11 @@ ${arg.stack}`;
607
607
  stack = serialized.stack;
608
608
  errorType = serialized.name;
609
609
  } else {
610
- stack = new Error().stack;
610
+ const lines = new Error().stack?.split("\n");
611
+ if (lines) {
612
+ const isV8 = lines[0]?.trimStart().startsWith("Error");
613
+ stack = lines.slice(isV8 ? 2 : 1).join("\n");
614
+ }
611
615
  }
612
616
  }
613
617
  queueMicrotask(() => {
package/dist/index.mjs CHANGED
@@ -319,7 +319,7 @@ var LEVEL_ORDER = {
319
319
  ERROR: 3,
320
320
  FATAL: 4
321
321
  };
322
- var SDK_VERSION = "0.1.3";
322
+ var SDK_VERSION = "0.1.4";
323
323
  var DEFAULT_BASE_URL = "https://log.terodato.com";
324
324
  var BATCH_SIZE = 50;
325
325
  var MAX_BUFFER_SIZE = 1e3;
@@ -580,7 +580,11 @@ ${arg.stack}`;
580
580
  stack = serialized.stack;
581
581
  errorType = serialized.name;
582
582
  } else {
583
- stack = new Error().stack;
583
+ const lines = new Error().stack?.split("\n");
584
+ if (lines) {
585
+ const isV8 = lines[0]?.trimStart().startsWith("Error");
586
+ stack = lines.slice(isV8 ? 2 : 1).join("\n");
587
+ }
584
588
  }
585
589
  }
586
590
  queueMicrotask(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remote-logger/sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "JavaScript SDK for Remote Logger",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",