Skip to content

Commit 644ebb2

Browse files
committed
fix: missing updates for logger.ts
1 parent 93608e0 commit 644ebb2

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

packages/core/src/logger.ts

+34-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
class ElizaLogger {
1+
import settings from "./settings.ts";
2+
import { Logger, ILogObjMeta, ILogObj } from "tslog";
3+
4+
interface IElizaLogger extends Logger<IElizaLogger> {
5+
progress(message: string): void;
6+
}
7+
8+
class ElizaLogger implements IElizaLogger {
29
constructor() {
310
// Check if we're in Node.js environment
411
this.isNode =
@@ -7,7 +14,7 @@ class ElizaLogger {
714
process.versions.node != null;
815

916
// Set verbose based on environment
10-
this.verbose = this.isNode ? process.env.verbose === "true" : false;
17+
this.verbose = this.isNode ? settings.VERBOSE === "true" : false;
1118
}
1219

1320
private isNode: boolean;
@@ -173,6 +180,7 @@ class ElizaLogger {
173180
}
174181
}
175182

183+
// @ts-ignore - custom implementation
176184
log(...strings) {
177185
this.#logWithStyle(strings, {
178186
fg: "white",
@@ -182,6 +190,7 @@ class ElizaLogger {
182190
});
183191
}
184192

193+
// @ts-ignore - custom implementation
185194
warn(...strings) {
186195
this.#logWithStyle(strings, {
187196
fg: "yellow",
@@ -191,6 +200,7 @@ class ElizaLogger {
191200
});
192201
}
193202

203+
// @ts-ignore - custom implementation
194204
error(...strings) {
195205
this.#logWithStyle(strings, {
196206
fg: "red",
@@ -200,6 +210,7 @@ class ElizaLogger {
200210
});
201211
}
202212

213+
// @ts-ignore - custom implementation
203214
info(...strings) {
204215
this.#logWithStyle(strings, {
205216
fg: "blue",
@@ -209,15 +220,7 @@ class ElizaLogger {
209220
});
210221
}
211222

212-
success(...strings) {
213-
this.#logWithStyle(strings, {
214-
fg: "green",
215-
bg: "",
216-
icon: "\u2713",
217-
groupTitle: ` ${this.successesTitle}`,
218-
});
219-
}
220-
223+
// @ts-ignore - custom implementation
221224
debug(...strings) {
222225
if (!this.verbose) return;
223226
this.#logWithStyle(strings, {
@@ -228,6 +231,15 @@ class ElizaLogger {
228231
});
229232
}
230233

234+
success(...strings) {
235+
this.#logWithStyle(strings, {
236+
fg: "green",
237+
bg: "",
238+
icon: "\u2713",
239+
groupTitle: ` ${this.successesTitle}`,
240+
});
241+
}
242+
231243
assert(...strings) {
232244
this.#logWithStyle(strings, {
233245
fg: "cyan",
@@ -236,6 +248,17 @@ class ElizaLogger {
236248
groupTitle: ` ${this.assertsTitle}`,
237249
});
238250
}
251+
252+
progress(message: string) {
253+
if (this.isNode) {
254+
// Clear the current line and move cursor to beginning
255+
process.stdout.clearLine(0);
256+
process.stdout.cursorTo(0);
257+
process.stdout.write(message);
258+
} else {
259+
console.log(message);
260+
}
261+
}
239262
}
240263

241264
export const elizaLogger = new ElizaLogger();

0 commit comments

Comments
 (0)