Hacker News new | ask | show | jobs
by the_af 1507 days ago
One thing that it takes some time to understand (and to teach to junior devs) is not only to add logs, but also useful logs.

The stages of understanding go like this, in my experience:

1. Log nothing.

2. Upon being told to log things, write mostly useless logs: "Entering f() function", "leaving f() function". When f() fails, who knows what happened?

3. Upon being taught to add context so that logs can actually be used to troubleshoot problems, "entering f() with id 123", "id is 123", "writing 123", etc.

4. Enlightenment usually comes when logs include necessary info but are not redundant, are not noisy, and can actually be used to track down problems. Of course, improvement at step 4 is always ongoing, for all of us.

2 comments

In my experience, (4) happens when the junior SDE is first on call responding to a problem happening with code they wrote.

They experience the problem with their own logging and realize through debugging their code what information they really wanted all along.

5. Get a ticket in your backlog to reduce logging because you've blown through your annual Datadog budget and it's only May.