chia-agent 13.2.0-beta.2 → 13.2.0-beta.3
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/CHANGELOG.md +1 -0
- package/daemon/index.js +1 -1
- package/logger.d.ts +4 -4
- package/logger.js +45 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/daemon/index.js
CHANGED
|
@@ -85,7 +85,7 @@ class Daemon {
|
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
87
87
|
else if (this._connectedUrl) {
|
|
88
|
-
logger_1.getLogger().error(
|
|
88
|
+
logger_1.getLogger().error("Connection is still active. Please close living connection first");
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
91
|
logger_1.getLogger().debug(`Opening websocket connection to ${daemonServerURL}`);
|
package/logger.d.ts
CHANGED
|
@@ -14,9 +14,9 @@ declare class Logger {
|
|
|
14
14
|
setLogLevel(level: TLogLevel): void;
|
|
15
15
|
shouldWrite(logLevel: TLogLevel): boolean;
|
|
16
16
|
formatMessage(level: TLogLevel, body: string): string;
|
|
17
|
-
debug(msg:
|
|
18
|
-
info(msg:
|
|
19
|
-
warning(msg:
|
|
20
|
-
error(msg:
|
|
17
|
+
debug(msg: any): void;
|
|
18
|
+
info(msg: any): void;
|
|
19
|
+
warning(msg: any): void;
|
|
20
|
+
error(msg: any): void;
|
|
21
21
|
}
|
|
22
22
|
export {};
|
package/logger.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLogger = exports.setLogLevel = exports.getLogLevel = void 0;
|
|
4
4
|
const logPriority = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
none: 9999,
|
|
6
|
+
error: 4,
|
|
7
|
+
warning: 3,
|
|
8
|
+
info: 2,
|
|
9
|
+
debug: 1,
|
|
10
10
|
};
|
|
11
11
|
class ConsoleWriter {
|
|
12
12
|
write(message) {
|
|
@@ -18,6 +18,42 @@ function getLogLevel() { return currentLogLevel; }
|
|
|
18
18
|
exports.getLogLevel = getLogLevel;
|
|
19
19
|
function setLogLevel(logLevel) { return currentLogLevel = logLevel; }
|
|
20
20
|
exports.setLogLevel = setLogLevel;
|
|
21
|
+
function stringify(obj, indent) {
|
|
22
|
+
if (typeof obj === "string") {
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
else if (typeof obj === "number") {
|
|
26
|
+
return `${obj}`;
|
|
27
|
+
}
|
|
28
|
+
else if (typeof obj === "boolean") {
|
|
29
|
+
return `${obj}`;
|
|
30
|
+
}
|
|
31
|
+
else if (typeof obj === "bigint") {
|
|
32
|
+
return `${obj}`;
|
|
33
|
+
}
|
|
34
|
+
else if (typeof obj === "symbol") {
|
|
35
|
+
return obj.toString();
|
|
36
|
+
}
|
|
37
|
+
else if (typeof obj === "undefined") {
|
|
38
|
+
return "undefined";
|
|
39
|
+
}
|
|
40
|
+
else if (typeof obj === "function") {
|
|
41
|
+
return "[Function]";
|
|
42
|
+
}
|
|
43
|
+
const seen = new WeakSet();
|
|
44
|
+
return JSON.stringify(obj, (k, v) => {
|
|
45
|
+
if (typeof v === "object" && v !== null) {
|
|
46
|
+
if (seen.has(v)) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
seen.add(v);
|
|
50
|
+
}
|
|
51
|
+
else if (typeof v === "bigint") {
|
|
52
|
+
return `${v}n`;
|
|
53
|
+
}
|
|
54
|
+
return v;
|
|
55
|
+
}, indent);
|
|
56
|
+
}
|
|
21
57
|
const loggers = {};
|
|
22
58
|
function getLogger(writer) {
|
|
23
59
|
const w = writer || "console";
|
|
@@ -56,22 +92,22 @@ class Logger {
|
|
|
56
92
|
}
|
|
57
93
|
debug(msg) {
|
|
58
94
|
if (this.shouldWrite("debug")) {
|
|
59
|
-
this._writer.write(this.formatMessage("debug", msg));
|
|
95
|
+
this._writer.write(this.formatMessage("debug", stringify(msg)));
|
|
60
96
|
}
|
|
61
97
|
}
|
|
62
98
|
info(msg) {
|
|
63
99
|
if (this.shouldWrite("info")) {
|
|
64
|
-
this._writer.write(this.formatMessage("info", msg));
|
|
100
|
+
this._writer.write(this.formatMessage("info", stringify(msg)));
|
|
65
101
|
}
|
|
66
102
|
}
|
|
67
103
|
warning(msg) {
|
|
68
104
|
if (this.shouldWrite("warning")) {
|
|
69
|
-
this._writer.write(this.formatMessage("warning", msg));
|
|
105
|
+
this._writer.write(this.formatMessage("warning", stringify(msg)));
|
|
70
106
|
}
|
|
71
107
|
}
|
|
72
108
|
error(msg) {
|
|
73
109
|
if (this.shouldWrite("error")) {
|
|
74
|
-
this._writer.write(this.formatMessage("error", msg));
|
|
110
|
+
this._writer.write(this.formatMessage("error", stringify(msg)));
|
|
75
111
|
}
|
|
76
112
|
}
|
|
77
113
|
}
|