feat(logging): added support for multiple lines
This commit is contained in:
parent
2534e50ef9
commit
454f837184
1 changed files with 54 additions and 30 deletions
|
@ -69,49 +69,73 @@ switch (loglevel.toLowerCase()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function verbose(message: string, scope?: ELoggingScope): void {
|
export function verbose(message: string, scope?: ELoggingScope): void {
|
||||||
if(verboseLevel)
|
const splitMultiline = message.split('\n');
|
||||||
if(scope)
|
|
||||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {white.bold [VERBOSE]}: {white ${message}}`);
|
splitMultiline.forEach((val) => {
|
||||||
|
if (verboseLevel)
|
||||||
|
if (scope)
|
||||||
|
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {white.bold [VERBOSE]}: {white ${val}}`);
|
||||||
else
|
else
|
||||||
console.log(logger`{grey (${date})} {white.bold [VERBOSE]}: {white ${message}}`);
|
console.log(logger`{grey (${date})} {white.bold [VERBOSE]}: {white ${val}}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function debug(message: string, scope?: ELoggingScope): void {
|
export function debug(message: string, scope?: ELoggingScope): void {
|
||||||
if(debugLevel)
|
const splitMultiline = message.split('\n');
|
||||||
if(scope)
|
|
||||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {blue.bold [DEBUG]}: {blue ${message}}`);
|
splitMultiline.forEach((val) => {
|
||||||
|
if (debugLevel)
|
||||||
|
if (scope)
|
||||||
|
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {blue.bold [DEBUG]}: {blue ${val}}`);
|
||||||
else
|
else
|
||||||
console.log(logger`{grey (${date})} {blue.bold [DEBUG]}: {blue ${message}}`);
|
console.log(logger`{grey (${date})} {blue.bold [DEBUG]}: {blue ${val}}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function info(message: string, scope?: ELoggingScope): void {
|
export function info(message: string, scope?: ELoggingScope): void {
|
||||||
|
const splitMultiline = message.split('\n');
|
||||||
|
|
||||||
|
splitMultiline.forEach((val) => {
|
||||||
if (infoLevel)
|
if (infoLevel)
|
||||||
if(scope)
|
if(scope)
|
||||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {green.bold [INFO]}: {green ${message}}`);
|
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {green.bold [INFO]}: {green ${val}}`);
|
||||||
else
|
else
|
||||||
console.log(logger`{grey (${date})} {green.bold [INFO]}: {green ${message}}`);
|
console.log(logger`{grey (${date})} {green.bold [INFO]}: {green ${val}}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function warn(message: string, scope?: ELoggingScope): void {
|
export function warn(message: string, scope?: ELoggingScope): void {
|
||||||
if(warnLevel)
|
const splitMultiline = message.split('\n');
|
||||||
if(scope)
|
|
||||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {yellow.bold [WARN]}: {yellow ${message}}`);
|
splitMultiline.forEach((val) => {
|
||||||
|
if (warnLevel)
|
||||||
|
if (scope)
|
||||||
|
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {yellow.bold [WARN]}: {yellow ${val}}`);
|
||||||
else
|
else
|
||||||
console.log(logger`{grey (${date})} {yellow.bold [WARN]}: {yellow ${message}}`);
|
console.log(logger`{grey (${date})} {yellow.bold [WARN]}: {yellow ${val}}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function error(message: string, scope?: ELoggingScope): void {
|
export function error(message: string, scope?: ELoggingScope): void {
|
||||||
if(errorLevel)
|
const splitMultiline = message.split('\n');
|
||||||
if(scope)
|
|
||||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {bold.underline.rgb(255, 165, 0) [ERROR]}: {underline.rgb(255, 165, 0) ${message}}`);
|
splitMultiline.forEach((val) => {
|
||||||
|
if (errorLevel)
|
||||||
|
if (scope)
|
||||||
|
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {bold.underline.rgb(255, 165, 0) [ERROR]}: {underline.rgb(255, 165, 0) ${val}}`);
|
||||||
else
|
else
|
||||||
console.log(logger`{grey (${date})} {bold.underline.rgb(255, 165, 0) [ERROR]}: {underline.rgb(255, 165, 0) ${message}}`);
|
console.log(logger`{grey (${date})} {bold.underline.rgb(255, 165, 0) [ERROR]}: {underline.rgb(255, 165, 0) ${val}}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fatal(message: string, scope?: ELoggingScope): void {
|
export function fatal(message: string, scope?: ELoggingScope): void {
|
||||||
if(fatalLevel)
|
const splitMultiline = message.split('\n');
|
||||||
if(scope)
|
|
||||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {red.bold.underline [FATAL]}: {red.underline ${message}}`);
|
splitMultiline.forEach((val) => {
|
||||||
|
if (fatalLevel)
|
||||||
|
if (scope)
|
||||||
|
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {red.bold.underline [FATAL]}: {red.underline ${val}}`);
|
||||||
else
|
else
|
||||||
console.log(logger`{grey (${date})} {red.bold.underline [FATAL]}: {red.underline ${message}}`);
|
console.log(logger`{grey (${date})} {red.bold.underline [FATAL]}: {red.underline ${val}}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue