@@ -32,8 +32,8 @@ export class TextFormatter implements Formatter {
32
32
constructor ( private config : ClarityConfig ) { }
33
33
34
34
async format ( entry : LogEntry , forFile : boolean = false ) : Promise < string > {
35
- const timestamp = this . config . timestamp ? `${ colors . gray ( entry . timestamp . toISOString ( ) ) } ` : ''
36
- const name = colors . gray ( `[${ entry . name } ]` )
35
+ const timestamp = this . config . timestamp ? `${ colors . colorize ( entry . timestamp . toISOString ( ) , colors . gray ) } ` : ''
36
+ const name = colors . colorize ( `[${ entry . name } ]` , colors . gray )
37
37
38
38
const levelSymbols : Record < LogLevel , string > = {
39
39
debug : s ( '🔍' , 'D' ) ,
@@ -43,7 +43,7 @@ export class TextFormatter implements Formatter {
43
43
error : s ( '❌' , '×' ) ,
44
44
}
45
45
46
- const levelColors : Record < LogLevel , ( text : string ) => string > = {
46
+ const levelColors : Record < LogLevel , string > = {
47
47
debug : colors . gray ,
48
48
info : colors . blue ,
49
49
success : colors . green ,
@@ -67,7 +67,7 @@ export class TextFormatter implements Formatter {
67
67
68
68
const symbol = this . config . colors ? levelSymbols [ entry . level ] : ''
69
69
message = this . config . colors
70
- ? levelColors [ entry . level ] ( message )
70
+ ? colors . colorize ( message , levelColors [ entry . level ] )
71
71
: message
72
72
73
73
// For file output, put timestamp at beginning
@@ -108,10 +108,10 @@ export class TextFormatter implements Formatter {
108
108
if ( funcLocationParts . length > 1 ) {
109
109
const fnName = funcLocationParts [ 0 ]
110
110
const location = funcLocationParts [ 1 ] . replace ( ')' , '' )
111
- return ` ${ colors . gray ( `at ${ ANSI . cyan } ${ fnName } ${ ANSI . reset } (${ location } )` ) } `
111
+ return ` ${ colors . colorize ( `at ${ colors . colorize ( fnName , ANSI . cyan ) } (${ location } )` , colors . gray ) } `
112
112
}
113
113
}
114
- return ` ${ colors . gray ( line . trim ( ) ) } `
114
+ return ` ${ colors . colorize ( line . trim ( ) , colors . gray ) } `
115
115
}
116
116
return ` ${ line } `
117
117
} )
0 commit comments