Hacker News .hnnew | past | comments | ask | show | jobs | submitlogin

I often use this technique in my dev debug logs. If the last print() was more than a few seconds ago, it also prints “(2.4 seconds passed)” in gray text before printing another line. This helps with visually separating debug requests, button clicks, etc.

Mine is not a tool, I just define my log function that tracks last call time.

  const now = Date.now()
  if (now - last_time >= 2000) {
    console.log(…)
  }
  last_time = now
  console.log(…args)
Things like that should be in all dev toolboxes by default, I think. It’s amazing how we create animated experiences etc for users but when it comes to development it’s just println(). The cobbler’s children go barefoot.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: