Skip to content

Commit

Permalink
[Task] #34 colorize prefix in console
Browse files Browse the repository at this point in the history
  • Loading branch information
Type-Style committed Feb 13, 2024
1 parent c79dee8 commit aad9b34
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/scripts/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export default {
const consoleMessage = structuredClone(content); // create clone so response output is not "further" affected
consoleMessage.message = messageAsString; // gitbash output improvement (w/o objects in arrays appear as [Object])
content = consoleMessage;
} else if (typeof content == "string") {
const prefix = content.match(/^\[\w+\]/);
if (prefix?.length) {
content = content.replace(prefix[0], chalk.red(prefix[0]));
}
}
console.error(content); // log string right away or processed Object

Expand Down

0 comments on commit aad9b34

Please sign in to comment.