Paxton Terry
Infrastructure

Console Logging is for Losers

Or, in other words, you're not a real programmer until you write your own logging utility

One of the first things you learn in your programming journey is how to write the famous Hello World program.

If Javascript was your first language (like me), it might have looked something like this.

console.log("Hello, World!");

From the beginning, you learn how easy it is in a higher level language to print to stdout. And for most programmers (especially in web programming), that's where it stays. My first experience with logging workflows happened at my first software job as a web developer. This is basically what it was -

  1. Log the output you want to the process stdout.
  2. Ship those logs to logz.io
  3. Never look at them again until something broke.

Most of the time, the things that were being logged were either error messages, or debugging messages that never got removed.

Maybe something like this ->

const data = {
  id: 78912,
    customer: "Jason Sweet",
    quantity: 1,
    price: 18.00,
    details: {
      order_date: "2025-01-01",
      status: "Shipped"
    }
  };

const out = JSON.stringify(data, null, 2);
console.log(out);
/*

*/

Which would get logged like this in stdout

{
  "id": 78912,
  "customer": "Jason Sweet",
  "quantity": 1,
  "price": 18,
  "details": {
    "order_date": "2025-01-01",
    "status": "Shipped"
  }
}

Pro Tip: if you have a nested object structure like above, instead of invoking JSON.stringify, you can instead use console.dir, which is specifically made for the purpose of printing the properties of javascript objects.

You can read more about it in the mdn docs

console.dir(data, { depth: null })

When these logs would be shipped to an aggregator like logz.io, each individual line was it's own "log". This made analyzing or parsing through said logs basically impossible. Forget about human readable, the aggregator barely knew what was going on. It took a single experience of trying to parse through these logs to find an error message to realize there had to be a better way.