Skip to content

Commit

Permalink
Fix: do not colorize non-string log message
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam committed Oct 14, 2023
1 parent f6bdaac commit a362206
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 0 additions & 2 deletions server/monitor-types/real-browser-monitor-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ if (process.platform === "win32") {
];
}

log.debug("chrome", allowedList);

/**
* Is the executable path allowed?
* @param {string} executablePath Path to executable
Expand Down
16 changes: 14 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,25 @@ class Logger {
console.warn(timePart, modulePart, levelPart, msg);
}
else if (level === "ERROR") {
let msgPart = exports.CONSOLE_STYLE_FgRed + msg + exports.CONSOLE_STYLE_Reset;
let msgPart;
if (typeof msg === "string") {
msgPart = exports.CONSOLE_STYLE_FgRed + msg + exports.CONSOLE_STYLE_Reset;
}
else {
msgPart = msg;
}
console.error(timePart, modulePart, levelPart, msgPart);
}
else if (level === "DEBUG") {
if (exports.isDev) {
timePart = exports.CONSOLE_STYLE_FgGray + now + exports.CONSOLE_STYLE_Reset;
let msgPart = exports.CONSOLE_STYLE_FgGray + msg + exports.CONSOLE_STYLE_Reset;
let msgPart;
if (typeof msg === "string") {
msgPart = exports.CONSOLE_STYLE_FgGray + msg + exports.CONSOLE_STYLE_Reset;
}
else {
msgPart = msg;
}
console.debug(timePart, modulePart, levelPart, msgPart);
}
}
Expand Down
16 changes: 13 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,23 @@ class Logger {
} else if (level === "WARN") {
console.warn(timePart, modulePart, levelPart, msg);
} else if (level === "ERROR") {
let msgPart = CONSOLE_STYLE_FgRed + msg + CONSOLE_STYLE_Reset;
let msgPart :string;
if (typeof msg === "string") {
msgPart = CONSOLE_STYLE_FgRed + msg + CONSOLE_STYLE_Reset;
} else {
msgPart = msg;
}
console.error(timePart, modulePart, levelPart, msgPart);
} else if (level === "DEBUG") {
if (isDev) {
timePart = CONSOLE_STYLE_FgGray + now + CONSOLE_STYLE_Reset;
let msgPart = CONSOLE_STYLE_FgGray + msg + CONSOLE_STYLE_Reset;
console.debug(timePart, modulePart, levelPart, msgPart );
let msgPart :string;
if (typeof msg === "string") {
msgPart = CONSOLE_STYLE_FgGray + msg + CONSOLE_STYLE_Reset;
} else {
msgPart = msg;
}
console.debug(timePart, modulePart, levelPart, msgPart);
}
} else {
console.log(timePart, modulePart, msg);
Expand Down

0 comments on commit a362206

Please sign in to comment.