fix(core): update
This commit is contained in:
parent
592178f066
commit
a03e821c02
@ -34,7 +34,37 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
|
||||
/**
|
||||
* enables console logging
|
||||
*/
|
||||
public enableConsole(optionsArg?: { }) {
|
||||
public enableConsole(optionsArg?: { captureAll: boolean }) {
|
||||
if (globalThis.process && optionsArg && optionsArg.captureAll) {
|
||||
const process = globalThis.process;
|
||||
const write = process.stdout.write;
|
||||
process.stdout.write = (...args) => {
|
||||
const logString: string = args[0];
|
||||
if (!logString.startsWith('LOG') && typeof logString === 'string') {
|
||||
switch (true) {
|
||||
case logString.substr(0, 20).includes('Error:'):
|
||||
this.log('error', logString);
|
||||
break;
|
||||
default:
|
||||
this.log('info', logString);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// fileStream.write(args[0]);
|
||||
write.apply(process.stdout, args);
|
||||
return true;
|
||||
};
|
||||
|
||||
process.stderr.write = (...args) => {
|
||||
if (!args[0].startsWith('LOG')) {
|
||||
this.log('error', args[0]);
|
||||
return;
|
||||
}
|
||||
// fileStream.write(args[0]);
|
||||
write.apply(process.stderr, args);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
this.consoleEnabled = true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user