-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to pretty print error log #1925
Labels
Comments
Note to myself: The following code produces the result above (in printIndent (level) {
if(level === 0) {
return '';
}
return `${' '.repeat(level * 2)}- `;
}
printIndicatorSummary (result, level = 1) {
let message = ''
for(const [key, value] of Object.entries(result)) {
if(typeof value === 'object' && value !== null) {
message += `${this.printIndent(level)}${key}:\n${this.printIndicatorSummary(value, level + 1)}\n`;
} else {
message += `${this.printIndent(level)}${key}: ${value}\n`
}
}
return message;
}
printSummary (result){
let message = '';
for(const [key, value] of Object.entries(result)) {
if(value.status === "up") {
message += `\x1b[0m\x1b[32m${key}: ✅\n${this.printIndicatorSummary(value)}\x1b[0m\n`
}
if(value.status === "down") {
message += `\x1b[0m\x1b[31m${key}: ❌\n${this.printIndicatorSummary(value)}\x1b[0m\n`
}
}
return message;
}
/**
* Logs an error message of terminus
* @param message The log message
* @param error The error which was thrown
*/
logError(message, causes) {
message = `${message}\n\n${this.printSummary(causes)}`;
this.logger.error(message);
} |
BrunnerLivio
changed the title
Option to pretty print in log
Option to pretty print error log
Jul 11, 2022
Released with 9.1.0 🎉 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
The JSON which is printed during an error message is not really readable.
Describe the solution you'd like
Better readability of the current health check status. Example:
This shall be enabled via:
This would allow one to switch between different log styles depending on the environment
Teachability, documentation, adoption, migration strategy
The
json
-option would remain the default in case someone uses a log parser tool (e.g. Splunk) to not break any changes.The docs should recommend to use the code-snippet above. (
json
in prod butpretty-emoji
locally)What is the motivation / use case for changing the behavior?
The JSON which is printed during an error message is not really readable.
The text was updated successfully, but these errors were encountered: