1
- class ElizaLogger {
1
+ import settings from "./settings.ts" ;
2
+ import { Logger } from "tslog" ;
3
+
4
+ interface IElizaLogger extends Logger < IElizaLogger > {
5
+ progress ( message : string ) : void ;
6
+ }
7
+
8
+ class ElizaLogger implements IElizaLogger {
2
9
constructor ( ) {
3
10
// Check if we're in Node.js environment
4
11
this . isNode =
@@ -7,7 +14,7 @@ class ElizaLogger {
7
14
process . versions . node != null ;
8
15
9
16
// Set verbose based on environment
10
- this . verbose = this . isNode ? process . env . verbose === "true" : false ;
17
+ this . verbose = this . isNode ? settings . VERBOSE === "true" : false ;
11
18
}
12
19
13
20
private isNode : boolean ;
@@ -173,6 +180,7 @@ class ElizaLogger {
173
180
}
174
181
}
175
182
183
+ // @ts -expect-error- custom implementation
176
184
log ( ...strings ) {
177
185
this . #logWithStyle( strings , {
178
186
fg : "white" ,
@@ -182,6 +190,7 @@ class ElizaLogger {
182
190
} ) ;
183
191
}
184
192
193
+ // @ts -expect-error- custom implementation
185
194
warn ( ...strings ) {
186
195
this . #logWithStyle( strings , {
187
196
fg : "yellow" ,
@@ -191,6 +200,7 @@ class ElizaLogger {
191
200
} ) ;
192
201
}
193
202
203
+ // @ts -expect-error- custom implementation
194
204
error ( ...strings ) {
195
205
this . #logWithStyle( strings , {
196
206
fg : "red" ,
@@ -200,6 +210,7 @@ class ElizaLogger {
200
210
} ) ;
201
211
}
202
212
213
+ // @ts -expect-error- custom implementation
203
214
info ( ...strings ) {
204
215
this . #logWithStyle( strings , {
205
216
fg : "blue" ,
@@ -209,15 +220,7 @@ class ElizaLogger {
209
220
} ) ;
210
221
}
211
222
212
- success ( ...strings ) {
213
- this . #logWithStyle( strings , {
214
- fg : "green" ,
215
- bg : "" ,
216
- icon : "\u2713" ,
217
- groupTitle : ` ${ this . successesTitle } ` ,
218
- } ) ;
219
- }
220
-
223
+ // @ts -expect-error- custom implementation
221
224
debug ( ...strings ) {
222
225
if ( ! this . verbose ) return ;
223
226
this . #logWithStyle( strings , {
@@ -228,6 +231,15 @@ class ElizaLogger {
228
231
} ) ;
229
232
}
230
233
234
+ success ( ...strings ) {
235
+ this . #logWithStyle( strings , {
236
+ fg : "green" ,
237
+ bg : "" ,
238
+ icon : "\u2713" ,
239
+ groupTitle : ` ${ this . successesTitle } ` ,
240
+ } ) ;
241
+ }
242
+
231
243
assert ( ...strings ) {
232
244
this . #logWithStyle( strings , {
233
245
fg : "cyan" ,
@@ -236,6 +248,17 @@ class ElizaLogger {
236
248
groupTitle : ` ${ this . assertsTitle } ` ,
237
249
} ) ;
238
250
}
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
+ }
239
262
}
240
263
241
264
export const elizaLogger = new ElizaLogger ( ) ;
0 commit comments