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 {
|
||||
if(verboseLevel)
|
||||
if(scope)
|
||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {white.bold [VERBOSE]}: {white ${message}}`);
|
||||
const splitMultiline = message.split('\n');
|
||||
|
||||
splitMultiline.forEach((val) => {
|
||||
if (verboseLevel)
|
||||
if (scope)
|
||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {white.bold [VERBOSE]}: {white ${val}}`);
|
||||
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 {
|
||||
if(debugLevel)
|
||||
if(scope)
|
||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {blue.bold [DEBUG]}: {blue ${message}}`);
|
||||
const splitMultiline = message.split('\n');
|
||||
|
||||
splitMultiline.forEach((val) => {
|
||||
if (debugLevel)
|
||||
if (scope)
|
||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {blue.bold [DEBUG]}: {blue ${val}}`);
|
||||
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 {
|
||||
const splitMultiline = message.split('\n');
|
||||
|
||||
splitMultiline.forEach((val) => {
|
||||
if (infoLevel)
|
||||
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
|
||||
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 {
|
||||
if(warnLevel)
|
||||
if(scope)
|
||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {yellow.bold [WARN]}: {yellow ${message}}`);
|
||||
const splitMultiline = message.split('\n');
|
||||
|
||||
splitMultiline.forEach((val) => {
|
||||
if (warnLevel)
|
||||
if (scope)
|
||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {yellow.bold [WARN]}: {yellow ${val}}`);
|
||||
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 {
|
||||
if(errorLevel)
|
||||
if(scope)
|
||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {bold.underline.rgb(255, 165, 0) [ERROR]}: {underline.rgb(255, 165, 0) ${message}}`);
|
||||
const splitMultiline = message.split('\n');
|
||||
|
||||
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
|
||||
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 {
|
||||
if(fatalLevel)
|
||||
if(scope)
|
||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {red.bold.underline [FATAL]}: {red.underline ${message}}`);
|
||||
const splitMultiline = message.split('\n');
|
||||
|
||||
splitMultiline.forEach((val) => {
|
||||
if (fatalLevel)
|
||||
if (scope)
|
||||
console.log(logger`{grey (${date})} {magenta.bold ${scope}} {red.bold.underline [FATAL]}: {red.underline ${val}}`);
|
||||
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