Hacker News new | ask | show | jobs
by ProfXponent 1483 days ago
I really cannot believe what I am reading in this thread.

It’s pretty trivial to setup a debugger in most IDE’s these days and share a config with your team.

Print logging falls flat on its face in async systems.

I feel like the ven diagram of people using text editors as a replacement for IDE’s and people doing print logging must be a circle.

4 comments

libs like https://docs.rs/tracing/latest/tracing/ (for rust, but i'm sure most languages have things like it) can make logging work for async programs. it achieves it by structuring the log in nested spans, instead of just appending a timestamp and thus losing which async task is related to which log line. alongside with https://github.com/tokio-rs/console it makes log-based debugging for async programs a breeze (tokio-console shows which async tasks are running, like a top(1) but for async tasks, and can show logs of a given task)

it's really fundamental to have good logging! both to discover issues as they unfold, and to debug past runs of the program for which you didn't know there was a problem and as such you didn't run the code in a debugger

I agree that logging is essential in any system, but I read most of the original comments as tossing console.log(foo) at various points to manually observe the outcome.

The approach you described is much more structured and absolutely vital.

It’s relatively easy to use logging in an async matter. One windows approach, for example, is to set a thread activityId. This allows you to track a specific operation or context across threads / time.

Use with a filtering tool to filter in on a specific area of concern on specific threads.

Bonus if your logging also is tracing and ingested into some big data or telemetry tool.

I have worked in many systems where using a debugger to debug the system is impossible. Not because it was hard to setup a debugger (it usually isn’t) but because the bug is in a distributed system, or a very high performance timing sensitive system, or a system where you have to run the code for hours to trigger the bug, the bug only happens on a system I don’t have access to but I can send logging to my system etc. Also, why would anybody prefer to manually do something that you can automate by programming code to detect the bugs and print() exactly the information you need to fix it? That doesn’t make sense to me. We have the technology (programming) to automate bug finding. Don’t do it manually. It doesn’t scale.
What do you mean by falls flat?