News for hackers. Stuff that matters.
Re:Ask HN: What change in your programming technique has bee... by mekster on Friday January 24, 2020 @08:43AM (#22138107)
Logger as an anonymous function.

I think literally every logger let's you log at a certain point as a single line that does not cover the context of the log.

  logger.info('Doing this and that',  function () {
    do_this()
    if(maybe) do_that()
  })
This way you know how much the log comment is supposed to cover as well as take a benchmark on the said context.

I can never think to just add a single line logger anymore.

This is much better than inserting comments in a code as comments can have no context except the line below.

You can add a function like,

logger.comment

and don't let it log anything to be comment syntax replacement.

Re:Ask HN: What change in your programming technique has bee... by stevenroose on Friday January 24, 2020 @08:48AM (#22138171)
Not an active HN user. There doesn't seem to be a downvote function..
Re:Ask HN: What change in your programming technique has bee... by mekster on Friday January 24, 2020 @08:55AM (#22138236)
I guess you can't downvote having below 500 points for yourself.

You can certainly add a comment on how you don't like it.