lmittmann/tint

Skip time, replace level with icon, and some other differences

StevenACoffman opened this issue · 2 comments

Hi! This is very cool. I really like how you differentiated the keys from the values. I was trying to figure out how to do something similar while still leaning on the TextHandler/JSONHandler

In my local console, I generally don't care much about the time of the log mesages, so I'd like to skip that field altogether. I chose to color the message per the level, and just use a unicode symbol for the level instead of "INF|DBG|WRN|ERR" string. I was curious about the source file and line number where the log messages came from, but I didn't want it particularly long.

Before I found this, I was making a similar thing inspired by apex/log cli, which is also colorful, but a bit more condensed. I'm not sure if it's interesting, but if you are interested, it looks like this:
Screen Shot 2023-03-26 at 5 56 49 PM
And the source code is here:
https://gist.github.com/StevenACoffman/d51ddab0d8af65e94ef88852f9fc1551

Hi @StevenACoffman, I do plan to include a source file/line option. You could hide the time in a hacky way by setting up the logger like this (however, this would add two spaces in front of every line):

slog.SetDefault(slog.New(tint.Options{TimeFormat: " "}.NewHandler(os.Stderr)))

The log format you describe seems to be quite different from the opinionated format of tint. Feel free to fork my code to output a format specific to your needs.

Thanks! I was mostly just pointing out some differences in a parallel evolution without really suggesting you change anything. Yours is great as is!

If you are interested, Uber's zap uses a different trimmed file/line mechanism to trim the path then the one I shared:
https://github.com/uber-go/zap/blob/a55bdc32f526699c3b4cc51a2cc97e944d02fbbf/zapcore/entry.go#L102-L136