fix(DestinationLocal): Fix debug log rendering, add fallback for unknown log levels, and correct error prefix typo in local destination
This commit is contained in:
@ -61,19 +61,22 @@ export class DestinationLocal implements ILogDestination {
|
||||
|
||||
// default logging
|
||||
private logToConsole(logPackageArg: ILogPackage) {
|
||||
let logString: string;
|
||||
try {
|
||||
logString =
|
||||
this.localBl[logPackageArg.level].prefix +
|
||||
const style = this.localBl[logPackageArg.level] ?? this.localBl.info;
|
||||
const logString =
|
||||
style.prefix +
|
||||
plugins.consolecolor.coloredString(
|
||||
logPackageArg.message,
|
||||
this.localBl[logPackageArg.level].textColor
|
||||
style.textColor
|
||||
);
|
||||
console.log(logString);
|
||||
return true;
|
||||
} catch (error) {
|
||||
// typo fix: use the defined error.prefix, not a non-existent errorPrefix
|
||||
console.log(
|
||||
this.localBl.errorPrefix + 'You seem to have tried logging something strange' + error
|
||||
this.localBl.error.prefix +
|
||||
'You seem to have tried logging something strange ' +
|
||||
error
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@ -89,6 +92,10 @@ export class DestinationLocal implements ILogDestination {
|
||||
prefix: plugins.consolecolor.coloredString(' silly ', 'white', 'blue') + ' ',
|
||||
textColor: 'blue',
|
||||
},
|
||||
debug: {
|
||||
prefix: plugins.consolecolor.coloredString(' debug ', 'gray', 'black') + ' ',
|
||||
textColor: 'gray',
|
||||
},
|
||||
error: {
|
||||
prefix:
|
||||
plugins.consolecolor.coloredString(' ', 'red', 'red') +
|
||||
|
Reference in New Issue
Block a user