Closed webbird closed 8 years ago
Seems like a nice feature, why not a PR?
Really? Maybe if it was a configurable option. I'm really feeling like this is a nice to have that may end up requiring more changes than expected.
But in the end, not something that would make or break someone's decision to use the library.
@onno-vos-dev @richjenks ?
(My personal opinion)
Personally, I'm not a fan of this sort of indenting. I think the log message gets separated too much from the loglevel and makes your eyes scan back and forth between the loglevel and the logmessage. I prefer my code and my logfiles to be as clean as possible with only the absolute necessary amount of whitespace. This fix clutters the logfile with unnecessary whitespace if you ask me.
@webbird If you really need this, you can TRY to use the custom logformat that PR https://github.com/katzgrau/KLogger/pull/54 has introduced. I just gave it 5 minutes and gave up because I couldn't get it to work but perhaps you can give it another go.
But again, in my opinion, you shouldn't be formatting your logfile in such a way to start with.
Can you elaborate on the use case for this?
Because if you're ending up reading your logfiles so frequently that you end up adjusting the formatting of your logfiles, I'd suggest you look at things like Logstash, Splunk or other tools that can help you plow through logfiles and make them visual and easily human readable.
Please, this was just for people who may need it too. I didn't want to start a lengthy discussion about pros and cons, likes and dislikes, or something else. It's something I found that it makes the logs more readable for me, not a feature request or anything. Just close this and that's it. Sorry for this.
I agree with @katzgrau and @onno-vos-dev
Perhaps this would be better as an example format param in the readme rather than a separate feature?
I don't think you can make calculations in the format param?
You can do what you like with the format param, as long as it returns a string.
I think it would have to be a special format param, like [level-padded]
Good idea, I'd support that.
What does everyone think of https://github.com/katzgrau/KLogger/commit/cbd026ded7ae21243badae7979bdfbfb6d2ce877
The reason I did it that way (ie, just whitespace) is that it gives the developer a bit of flexibility in how they arrange the log format.
I like it, does the job and is nice and simple.
@katzgrau I'm fine with this but will make a note that if you have a log-message which stretches multiple lines, you're still gonna have a messy log-file. Ideally you'd want to also pad the entire message to the same position so if a new-line is reached, that should be padded by the number of characters which are in "[{date}] [{level}]"
[2015-08-31 19:03:27.268881] [info] Short ribs fatback swine pastrami shankle, jowl beef.
[2015-08-31 19:03:27.268881] [emergency] Bacon ipsum dolor amet ball tip venison chuck landjaeger, tail frankfurter shankle pork short loin turducken pork chop tri-tip.
Ham hock tail turkey venison swine, cow tenderloin pastrami pork bacon tri-tip.
I'm fine with the commit you just made @katzgrau just giving my $0,02 that this will note solve larger logfiles. Which tends to happen when you add $context or append JSON-blobs to the message.
I see what you mean, but I don't think it's practical because there may be formats that don't begin with date and level. For example, if the format is "[{date}] [Project name] [{level}]" then it would be pretty tricky to indent subsequent lines.
@richjenks I know and I'm just adding my $0,02 that this won't be the magic bullet for the OCD-minded users of KLogger ;-)
@onno-vos-dev fair enough. If such people are that bothered, maybe they should just get wider monitors :)
@richjenks Agreed :+1: Either way, when you start having very verbose output, you're gonna get stuck with logfiles which may be hard to read by a human but they can be very useful for alarms, compliance or debugging reasons which is mainly why where I work, we produce very verbose logs.
Officially in the latest release (1.2.0)
I thought my log file would be more readable if all messages are indented with the same depth, no matter what
$level
. Example:original
nicer
So I changed line 553 (method
formatMessage()
) like this (original line is the commented one):Maybe it's helpful for someone.