Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
60ae0fed4e | |||
a03e821c02 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartlog",
|
"name": "@pushrocks/smartlog",
|
||||||
"version": "2.0.38",
|
"version": "2.0.39",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartlog",
|
"name": "@pushrocks/smartlog",
|
||||||
"version": "2.0.38",
|
"version": "2.0.39",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "minimalistic distributed and extensible logging tool",
|
"description": "minimalistic distributed and extensible logging tool",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -34,7 +34,37 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
|
|||||||
/**
|
/**
|
||||||
* enables console logging
|
* 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;
|
this.consoleEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user