Archived
0
0
Fork 0

feat(logging): added support for multiple lines

This commit is contained in:
Daryl Ronningen 2021-06-17 02:24:02 -07:00
parent 2534e50ef9
commit 454f837184
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B

View file

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