@@ -45,13 +45,13 @@ export class Logger {
45
45
return `\u001b[3${ code < 8 ? code : '8;5;' + code } ${ exporter . colors >= 2 ? decoration : '' } m${ value } \u001b[0m`
46
46
}
47
47
48
- static code ( name : string , exporter : Exporter ) {
48
+ static code ( name : string , level ?: false | ColorSupportLevel ) {
49
49
let hash = 0
50
50
for ( let i = 0 ; i < name . length ; i ++ ) {
51
51
hash = ( ( hash << 3 ) - hash ) + name . charCodeAt ( i ) + 13
52
52
hash |= 0
53
53
}
54
- const colors = ! exporter . colors ? [ ] : exporter . colors >= 2 ? c256 : c16
54
+ const colors = ! level ? [ ] : level >= 2 ? c256 : c16
55
55
return colors [ Math . abs ( hash ) % colors . length ]
56
56
}
57
57
@@ -124,7 +124,7 @@ export class Factory {
124
124
s : ( value ) => value ,
125
125
j : ( value ) => JSON . stringify ( value ) ,
126
126
c : ( value , exporter , logger ) => {
127
- return Logger . color ( exporter , Logger . code ( logger . name , exporter ) , value )
127
+ return Logger . color ( exporter , Logger . code ( logger . name , exporter . colors ) , value )
128
128
} ,
129
129
}
130
130
@@ -179,7 +179,7 @@ export namespace Exporter {
179
179
indent += this . showTime . length
180
180
output += Logger . color ( this , 8 , Time . template ( this . showTime ) )
181
181
}
182
- const code = Logger . code ( message . name , this )
182
+ const code = Logger . code ( message . name , this . colors )
183
183
const label = Logger . color ( this , code , message . name , ';1' )
184
184
const padLength = ( this . label ?. width ?? 0 ) + label . length - message . name . length
185
185
if ( this . label ?. align === 'right' ) {
0 commit comments