Log invalid values
Gpt wrote some slop today:
if(!valid(value)) {
console.log("Invalid value")
}
so people must be writing slop like that, let’s fix it:
if(!valid(value)) {
console.log(`Invalid value:${value}`)
}
Isn’t that so much nicer! Now we can see in our logs what the value is. And it’s DSV so we can parse it with cut if we need the value (usually in my paste buffer but occasionally elsewhere).
Sometimes I’ll write a sick little:
./run | tail -n1 | cut -d : -f 2 | pbcopy
or if I log JSON
console.log(JSON.stringify({s: "Invalid value", value})
I can get the value via:
./run | tail -n1 | jq .value -r | pbcopy
isn’t fast programming fun?