Live data from Hacker News

Logging as a code smell

dave.autonoma.ca

51–54 of 54 posts

Re: Logging as a code smell

#51
> sLogger.debug( "Not marking nodes down due to local pause" );

vs

> NodeMarkingInactiveEvent.publish( localPause );

The second statement is totally not logging because it doesn't have the word "logging" in it. ;-)

That being said... conceptually, I do like the generality of publishing an event that describes internal system state, rather than logging a string on some level. OTOH the logging is supposed to be human, rather than machine-readable. But it's also gotta be a heap more work to do it this way and, maybe you'll never know if the error occurred cause the service lost network for some period of time (because it can't write to the event bus either!)

Re: Logging as a code smell

#52

Logging is something you do for some future purpose. If I write a string in a log message, the future purpose is usually for me to read it later. The reasons in the post did not convince me on why my log messages should be structured. For example, why would I want to internationalize those messages?

No post body was provided.

Re: Logging as a code smell

#53
post #41

Earlier quoted context omitted.

So who has access, if at all ? If nobody has access, how is deployment done or setup ? Can you imagine the "deployer" person ... learning or being replaced by a developer ? This is an organisational weakness not to have figured out a way to make the people responsible for production, also responsible for reproduction and bug fixing. I've seen companies with a full team of developers who never add new features but onl…

Lets's say you run a company and buy a piece of software. The business you're in is regulated and deals with people's personal information. Would you let a random coder come in an attach their laptop to your network and start digging around for a problem in their software? Especially if it's your ass on the line if any regulated data is seen by the wrong pair of eyes? Or would you just ship them the logs from their o…

> Would you let a random coder come in

No. But I would a proper Engineer. The same way I don’t go seek treatment in a mall, but rather in a legitimate medical clinic by real MDs.

Re: Logging as a code smell

#54
post #4

I'm not sure this article does a good enough job of explaining why it's a code smell. Aside from the event bus code looking slightly better, I don't see any big advantages. One disadvantage is that if you have a big class with lots of different events, you now have to import all of your events rather than just importing the singular logger. Typically I only resort to logging in situations where I don't want to propag…

Logs are useful because they give an idea of what was going on when a particular failure happened. More context than a call stack. > Pretty disappointed with the actual post. I am as well. What the author describes isn't new or novel, it's been in Windows in the form of ETW since the early 90's. And Windows wasn't the first OS to get it. Had the author taken a serious System/OS class he would have known. You can't bu…

It sounds like the thing you're missing is the concept of "context" not "logging". If you frame the question as what information do I need to diagnose a problem with this code if (and only if) it fails, and likewise what info when it succeeds do you end up with logging as the best solution? Probably not - events seem to be a better perspective on this.

>Had the author taken a serious System/OS class he would have known.

I'm guessing the author probably did so - this comes across as fairly ascerbic btw.

Post reply on HN