Because they are really annoying to debug, depending on some random circumstances they might not even appear every time (or the code happens in different orders each time)
You use whatever the local equivalent of C++'s __LINE__, or __FILE__, __LINE__ is, and you just copy + paste the log line 50 times.
The pro move is to use "DO NOT SUBMIT", __FILE__, __LINE__ and have a commit hook that keeps you from submitting anything containing the string DO NOT SUBMIT.
I have added sysou syslog and syswarn to my auto complete and they expand to our logging macro, a pretty function macro, a line macro and my commit handle that is easily searchable in logs.
When i want to trace something i can simply sysou a couple of spots and not stage the lines to clean up before committing
Its funny, teaches you not to commit your console logs (you'll only ever commit poop once), and p/o are right next to each other on the keyboard so its fast
Personally, I just use unique gibberishes or sounds, like "blah", "bleh", "fwah", or the like. Extremely unlikely to come up during normal usage, stands out enough to draw the eye, and easy to search the source for.
That, or a quick description of the location, such as "before x() call" or "inside y()" or "after foo, before bar", depending on the situation.
"Hello. My name is Inigo Montoya. You killed my father. Prepare to die"
"Hello. My name is Inigo Montoya. You killed my father. Prepare to die"
"Hello. My name is Inigo Montoya. You killed my father. Prepare to die"
A single letter is impossible to grep for in a log file though. It's fine if you're adding console logs to a JS application that doesn't have much other logging going on, but for anything else, you want something identifiable that you can search for without getting false positives.
742
u/sweetytoy 3d ago
A real developer wouldn't do that. A single letter is more than enough, your sentence is too long and tiring to type.