skedyul 0.3.6 → 0.3.7

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/dist/.build-stamp CHANGED
@@ -1 +1 @@
1
- 1771568589599
1
+ 1771569422848
@@ -20,7 +20,32 @@ function getLogContext() {
20
20
  return logContextStorage.getStore();
21
21
  }
22
22
  /**
23
- * Formats a log message with invocation context prepended as JSON
23
+ * Safely stringify a value for logging.
24
+ * Handles circular references and errors gracefully.
25
+ */
26
+ function safeStringify(value) {
27
+ if (value === undefined)
28
+ return 'undefined';
29
+ if (value === null)
30
+ return 'null';
31
+ if (typeof value === 'string')
32
+ return value;
33
+ if (typeof value === 'number' || typeof value === 'boolean')
34
+ return String(value);
35
+ if (value instanceof Error) {
36
+ return `${value.name}: ${value.message}${value.stack ? `\n${value.stack}` : ''}`;
37
+ }
38
+ try {
39
+ return JSON.stringify(value);
40
+ }
41
+ catch {
42
+ return String(value);
43
+ }
44
+ }
45
+ /**
46
+ * Formats a log message with invocation context prepended as JSON.
47
+ * All arguments are stringified into a single line to ensure the context
48
+ * prefix appears on every line in Docker/CloudWatch logs.
24
49
  */
25
50
  function formatLogWithContext(args) {
26
51
  const context = getLogContext();
@@ -37,16 +62,15 @@ function formatLogWithContext(args) {
37
62
  ...(context.invocation.workflowId && { workflowId: context.invocation.workflowId }),
38
63
  ...(context.invocation.workflowRunId && { workflowRunId: context.invocation.workflowRunId }),
39
64
  };
40
- // If the first argument is a string, prepend context
41
- if (typeof args[0] === 'string') {
42
- return [`[${JSON.stringify(contextPrefix)}] ${args[0]}`, ...args.slice(1)];
43
- }
44
- // If the first argument is an object, merge context into it
45
- if (args[0] && typeof args[0] === 'object' && !Array.isArray(args[0])) {
46
- return [{ ...contextPrefix, ...args[0] }, ...args.slice(1)];
47
- }
48
- // Otherwise, prepend context as first argument
49
- return [contextPrefix, ...args];
65
+ const prefix = `[${JSON.stringify(contextPrefix)}]`;
66
+ // Stringify all arguments into a single line to ensure context appears on every log line
67
+ // This prevents multi-line object formatting from splitting logs across lines
68
+ const messageParts = args.map(arg => {
69
+ if (typeof arg === 'string')
70
+ return arg;
71
+ return safeStringify(arg);
72
+ });
73
+ return [`${prefix} ${messageParts.join(' ')}`];
50
74
  }
51
75
  // Store original console methods
52
76
  const originalConsole = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",