fix(core): update

This commit is contained in:
2024-05-18 01:15:16 +02:00
parent 459d3cc0e5
commit ff1192f09a
4 changed files with 5282 additions and 3239 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartlog',
version: '3.0.4',
description: 'minimalistic distributed and extensible logging tool'
version: '3.0.5',
description: 'A minimalistic, distributed, and extensible logging tool supporting centralized log management.'
}

View File

@ -37,34 +37,35 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
public enableConsole(optionsArg?: { captureAll: boolean }) {
if (globalThis.process && optionsArg && optionsArg.captureAll) {
const process = globalThis.process;
const write = process.stdout.write;
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
const originalStderrWrite = process.stderr.write.bind(process.stderr);
process.stdout.write = (...args: any) => {
const logString: string = args[0];
if (!logString || typeof logString.startsWith !== 'function') {
// lets continue as planned
} else 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);
if (!logString || typeof logString !== 'string') {
// continue as planned
return originalStdoutWrite(...args);
}
if (!logString.startsWith('LOG')) {
if (logString.includes('Error:')) {
this.log('error', logString);
} else {
this.log('info', logString);
}
return true;
}
// fileStream.write(args[0]);
write.apply(process.stdout, args);
return true;
return originalStdoutWrite(...args);
};
process.stderr.write = (...args: any) => {
if (!args[0].startsWith('LOG')) {
this.log('error', args[0]);
const logString: string = args[0];
if (!logString || typeof logString !== 'string' || !logString.startsWith('LOG')) {
this.log('error', logString);
return true;
}
// fileStream.write(args[0]);
write.apply(process.stderr, args);
return true;
return originalStderrWrite(...args);
};
}
this.consoleEnabled = true;