@motiadev/core 0.8.2-beta.140-930160 → 0.8.2-beta.140-504654
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.
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { RpcSender } from './rpc';
|
|
2
|
+
export type LogListener = (level: string, message: string, args?: unknown) => void;
|
|
2
3
|
export declare class Logger {
|
|
3
4
|
private readonly traceId;
|
|
4
5
|
private readonly flows;
|
|
5
6
|
private readonly sender;
|
|
7
|
+
private readonly listeners;
|
|
6
8
|
constructor(traceId: string, flows: string[], sender: RpcSender);
|
|
7
9
|
private _log;
|
|
8
10
|
info(message: string, args?: Record<string, unknown>): void;
|
|
9
11
|
error(message: string, args?: Record<string, unknown>): void;
|
|
10
12
|
debug(message: string, args?: Record<string, unknown>): void;
|
|
11
13
|
warn(message: string, args?: Record<string, unknown>): void;
|
|
14
|
+
addListener(listener: LogListener): void;
|
|
12
15
|
}
|
|
13
16
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/node/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,qBAAa,MAAM;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/node/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;AAElF,qBAAa,MAAM;IAIf,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;gBAG3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,SAAS;IAGpC,OAAO,CAAC,IAAI;IA0BZ,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI3D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI5D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI3D,WAAW,CAAC,QAAQ,EAAE,WAAW;CAGlC"}
|
package/dist/src/node/logger.js
CHANGED
|
@@ -6,6 +6,7 @@ class Logger {
|
|
|
6
6
|
this.traceId = traceId;
|
|
7
7
|
this.flows = flows;
|
|
8
8
|
this.sender = sender;
|
|
9
|
+
this.listeners = [];
|
|
9
10
|
}
|
|
10
11
|
_log(level, message, args) {
|
|
11
12
|
const argsCopy = args ? { ...args } : {};
|
|
@@ -26,6 +27,7 @@ class Logger {
|
|
|
26
27
|
msg: message,
|
|
27
28
|
};
|
|
28
29
|
this.sender.sendNoWait('log', logEntry);
|
|
30
|
+
this.listeners.forEach((listener) => listener(level, message, args));
|
|
29
31
|
}
|
|
30
32
|
info(message, args) {
|
|
31
33
|
this._log('info', message, args);
|
|
@@ -39,5 +41,8 @@ class Logger {
|
|
|
39
41
|
warn(message, args) {
|
|
40
42
|
this._log('warn', message, args);
|
|
41
43
|
}
|
|
44
|
+
addListener(listener) {
|
|
45
|
+
this.listeners.push(listener);
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
exports.Logger = Logger;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import time
|
|
2
|
-
from typing import Any, Dict, Optional
|
|
2
|
+
from typing import Any, Dict, Optional, Callable, List
|
|
3
3
|
from motia_rpc import RpcSender
|
|
4
4
|
|
|
5
|
+
LogListener = Callable[[str, str, Optional[Any]], None]
|
|
6
|
+
|
|
5
7
|
class Logger:
|
|
6
8
|
def __init__(self, trace_id: str, flows: list[str], rpc: RpcSender):
|
|
7
9
|
self.trace_id = trace_id
|
|
8
10
|
self.flows = flows
|
|
9
11
|
self.rpc = rpc
|
|
12
|
+
self.listeners: List[LogListener] = []
|
|
10
13
|
|
|
11
14
|
def _log(self, level: str, message: str, args: Optional[Dict[str, Any]] = None) -> None:
|
|
12
15
|
log_entry = {
|
|
@@ -27,6 +30,9 @@ class Logger:
|
|
|
27
30
|
|
|
28
31
|
self.rpc.send_no_wait('log', log_entry)
|
|
29
32
|
|
|
33
|
+
for listener in self.listeners:
|
|
34
|
+
listener(level, message, args)
|
|
35
|
+
|
|
30
36
|
def info(self, message: str, args: Optional[Any] = None) -> None:
|
|
31
37
|
self._log("info", message, args)
|
|
32
38
|
|
|
@@ -38,3 +44,6 @@ class Logger:
|
|
|
38
44
|
|
|
39
45
|
def warn(self, message: str, args: Optional[Any] = None) -> None:
|
|
40
46
|
self._log("warn", message, args)
|
|
47
|
+
|
|
48
|
+
def add_listener(self, listener: LogListener) -> None:
|
|
49
|
+
self.listeners.append(listener)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@motiadev/core",
|
|
3
3
|
"description": "Core functionality for the Motia framework, providing the foundation for building event-driven workflows.",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"version": "0.8.2-beta.140-
|
|
5
|
+
"version": "0.8.2-beta.140-504654",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@amplitude/analytics-node": "^1.3.8",
|
|
8
8
|
"ajv": "^8.17.1",
|