2018-03-01 22:39:03 +00:00
|
|
|
import * as plugins from './beautybrowser.plugins';
|
2018-11-13 00:32:39 +00:00
|
|
|
import { ILogDestination, ILogPackage } from '@pushrocks/smartlog-interfaces';
|
2018-03-01 22:39:03 +00:00
|
|
|
|
2018-11-13 00:32:39 +00:00
|
|
|
export class SmartlogDestinationDevtools implements ILogDestination {
|
2020-07-10 00:28:54 +00:00
|
|
|
public async handleLog(logPackageArg: ILogPackage) {
|
|
|
|
await this.logInBrowser(logPackageArg);
|
2018-03-01 22:39:03 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:28:54 +00:00
|
|
|
private async logInBrowser(logPackage: ILogPackage) {
|
2018-11-13 00:32:39 +00:00
|
|
|
switch (logPackage.level) {
|
2018-03-01 22:39:03 +00:00
|
|
|
case 'error':
|
|
|
|
console.log(
|
2018-11-13 00:32:39 +00:00
|
|
|
`%c Error: %c ${logPackage.message}`,
|
2018-03-01 22:39:03 +00:00
|
|
|
'background:#000000;color:#800000;',
|
|
|
|
'color:#000000;'
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'info':
|
|
|
|
console.log(
|
2018-11-13 00:32:39 +00:00
|
|
|
`%c Info: %c ${logPackage.message}`,
|
2018-03-01 22:39:03 +00:00
|
|
|
'background:#EC407A;color:#ffffff;',
|
|
|
|
'color:#EC407A;'
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'ok':
|
2018-11-13 00:32:39 +00:00
|
|
|
console.log(
|
|
|
|
`%c OK: %c ${logPackage.message}`,
|
|
|
|
'background:#000000;color:#8BC34A;',
|
|
|
|
'color:#000000;'
|
|
|
|
);
|
2018-03-01 22:39:03 +00:00
|
|
|
break;
|
|
|
|
case 'success':
|
|
|
|
console.log(
|
2018-11-13 00:32:39 +00:00
|
|
|
`%c Success: %c ${logPackage.message}`,
|
2018-03-01 22:39:03 +00:00
|
|
|
'background:#8BC34A;color:#ffffff;',
|
|
|
|
'color:#8BC34A;'
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'warn':
|
|
|
|
console.log(
|
2018-11-13 00:32:39 +00:00
|
|
|
`%c Warn: %c ${logPackage.message}`,
|
2018-03-01 22:39:03 +00:00
|
|
|
'background:#000000;color:#FB8C00;',
|
|
|
|
'color:#000000;'
|
|
|
|
);
|
|
|
|
break;
|
2018-11-13 00:32:39 +00:00
|
|
|
case 'note':
|
|
|
|
console.log(
|
|
|
|
`%c Note: %c ${logPackage.message}`,
|
|
|
|
'background:#42A5F5;color:#ffffff',
|
|
|
|
'color:#42A5F5;'
|
|
|
|
);
|
2018-03-01 22:39:03 +00:00
|
|
|
break;
|
|
|
|
default:
|
2018-11-13 00:32:39 +00:00
|
|
|
console.log(`unknown logType for "${logPackage.message}"`);
|
2018-03-01 22:39:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|