Closed JohnPolansky closed 8 months ago
Thanks for reporting. I don't exactly remember what happened.
@jsumners did you recall what happened on this one?
https://github.com/pinojs/pino-pretty/issues/140 is the last time this issue was discussed to the best of my recollection. In short, we've had two attempts performed at introducing the requested alignment. It seems it is not an easy feature to implement. I would rather not keep churning on the issue, but whomever feels strongly about it is welcome to work on it.
@JohnPolansky in pino-pretty v11.0.0 you now have access to the log level label and alignment in now possible. An example from my PR:
{
customPrettifiers: {
level: (logLevel, key, log, { label, labelColorized }) => {
// pad to fix alignment
// assuming longest level is 5 characters long
// and may be colorized
const paddedLabel = label.padEnd(5)
if(labelColorized !== label) {
const padDiff = paddedLabel.length - label.length;
return labelColorized.padEnd(labelColorized.length + padDiff);
}
return paddedLabel;
}
},
}
I'm using the following packages:
When I print out any messages using the
colorize()
option it appears that the message alignment is offAs you can see the INFO/WARN are throwing off messages which makes it a bit harder to read log messages. After searching various older posts I found a reference to this same issue back in 2021 that indicated this is an issue and it was fixed. Has something changed or am I missing a feature? https://github.com/pinojs/pino-pretty/pull/141
I also tried creating my own transport to
padEnd()
the log level, but this doesn't appear to work as belowHere is my full logger.js for review:
Thanks in advance for the help and the great tool.