
Show HN: Phuslu/Log – Structured Logging for Humans - phuslu
https://github.com/phuslu/log
======
jeffbee
These don't seem like very practical interfaces to me. One of the nice
features of glog is when you log at a high severity it flushes all the output
buffers and syncs the files. For this to work, the lowest level of glog has to
be aware of the severity. If you cut off that knowledge in the middle of your
interface (by serializing the log early, and passing down []byte) then you
don't have the information you need at the right place and time.

This library author should have realized their error when they needed to add
the parseLevel function to get the severity back out of the formatted output.

Aside from the weird interface, this library is pretty cavalier about unix
file i/o. This function will never notice that all its writes are failing.
[https://github.com/phuslu/log/blob/master/file.go#L67-L96](https://github.com/phuslu/log/blob/master/file.go#L67-L96)

~~~
marvinblum
Also little things like the w.mu.Unlock() at the end of the function instead
of using defer show that this was probably written by (Go) beginners.

------
atombender
This seems like an alternative to Zerolog, with some very small performance
improvements. I don't understand why you wouldn't just improve Zerolog, or at
least (if the original authors don't like your changes) just fork it. For me,
while this looks decent, it doesn't justify an entirely new project, nor do I
see any particular reason to switch.

Personally, I wish there was more focus on assimilating context.Context. While
I dislike Context for its virulence in codebases, it's a necessary evil at
this point. Correlating log statements with some request and following the
logic flow (not just within a single app, but across apps) becomes really
important in complex systems. The only way to really accomplish this is to
flow the logger through Context. You should never instantiate a new logger
except at the root of the program.

------
cube2222
For people interested in this, there's a great presentation, The Hunt For a
Logger Interface[0].

It describes how approaches to structured logging evolved over the years. I
especially like the idea of using closures as logging context values, which
get evaluated every time they're printed, it often greatly simplifies
contextual logging.

[0]: [https://go-
talks.appspot.com/github.com/ChrisHines/talks/str...](https://go-
talks.appspot.com/github.com/ChrisHines/talks/structured-logging/structured-
logging.slide#1)

------
kissgyorgy
Ooooh, stop the "for Humans" insult already! It suggests that all other
libraries are not "for humans" somehow. It's very offensive to everybody.
Terrible branding.

~~~
The_rationalist
It's still a valuable information, it claims that they focus on user
friendliness and fight clutter/cognitive overhead / boilerplate. How would you
alternatively communicate this?

~~~
aldanor
"... - Go Logging Made Simple" or whatever else. There's many ways to
communicate this without the stupid "for humans" tag.

