• (cs)

    Log it all (and send a copy to his email box, since he deems it so important).

    Oh, and frist!

  • MacHaggis (unregistered)

    I am missing the try...catch construction that sais "logFile.debug("something happened, moving on");"

  • Anonymous (unregistered)

    How is he going to log the inevitable "disk full" error?

  • Inigo Montoya (unregistered)
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

  • Bean (unregistered)

    // Begin text logFile.info("START: Comment Text"); logFile.debug("Write first line"); Logging is very important I don't see the problem. logFile.debug("Write second line"); It looks like a really good model logFile.debug("Captcha text line"); -capio logFile.info("END: Comment Text.");

  • Jan (unregistered)

    I'm betting he once made a log method that tried to log something. I know I did ;-)

  • Alastair (unregistered)

    I particularly love the fact that the success case is logged in minute detail, whilst in the error case the log message is... commented out.

    CAPTCHA: validus, which is close to describing the approach Christophe takes. Provided you add "in", that is.

  • Patrick (unregistered) in reply to Inigo Montoya

    INCONCEIVABLE!

    captcha: damnum - that damnum keeps overflowing. mayne i should make it a long...

  • Kurt (unregistered) in reply to Inigo Montoya

    Did you think about irony?

  • pixelbart (unregistered)

    Is it a coincidence that the code is about drugs?

  • paul (unregistered)

    AARGH! The use of whitespace and commentary seems to associate each log entry with the preceding line, but the content is actually associated with the following line.

    Surely this must be enough to convince management that he is completely deranged.

  • (cs)
    Christophe’s eight years makes him a “Senior” Developer
    Looks to me more like he's jumping straight to “Senile” Developer.
  • nitehawk (unregistered) in reply to paul

    This.

    Also, this looks like log4j. If I saw someone puling this crap I would put an appender in that redirects the log output to his email box.

  • Konrads (unregistered)

    logFile.info("Did XYZ"); logFile.debug("Just invoked logging function with arguments: "logFile.info("Did XYZ"); ""); logFile.debug("Just invoked logging function with arguments: "Just invoked logging function with arguments: "logFile.info("Did XYZ"); "");

    ...

  • (cs)

    I wonder if he always calls methods twice, once for logging and one for usage. That should work great for iterators...

  • nitehawk (unregistered) in reply to Inigo Montoya
    Inigo Montoya:
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    I am willing to bet the "senior" devs at that company really do consider themselves a Meritocracy based on seniority alone without regard to talent.

    In fact in my career I would say I get brow beat due to my age without regard to my experience. (10 years industry experience at 29). Then when I do get to an age where I can perform the same, I get scoffed because of the low amount of time at the company.

  • _sam (unregistered) in reply to Inigo Montoya
    Inigo Montoya:
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    whoosh.

  • qbolec (unregistered) in reply to pixelbart

    // gets drugs 'nuf said

  • (cs)

    Management probably sees that he wrote at least twice as much code as other developers and so he must be at least twice as productive. Make him the "senior" developer!

  • Wildcatmike (unregistered)

    TRWTF is that he didn't log the 'else' condition.

  • TST (unregistered)

    For a medical product, these logs are great because you can track everything that was done.

    Maybe I'm too anal, but I can't really see the WTF here. If the code passage is mission-critical I can understand the massive logging capabilities.

    TST

  • qbolec (unregistered)

    Actually it might be a good idea, to have logger plugged everywhere throughout the code as long as you have a nice way to turn it on/off, preferably at a module level granularity, when the interpreter is so slow that the impact is negligible anyway. In compiled languages you usually have preprocessor and thus can define log(x) to do nothing. But then you can not just turn it on/off on production. I can imagine some crazy way to force JITed languages to change implementation of log(x) on fly. Since I can, then probably it is already built in into .NET or something. But then again, I think it would be much better to have just a Trace mechanism built in into the interpreter/runtime environment/ or just a debugger, so that the developer doesn't have to echo each line of code to log(x).

    I found, that Math has a log function, but it doesn't do what I need, though.

  • (cs)
    logFile.debug("Getting particular drug information.");

    // gets drugs brandNameDrugs = Utils.formatDrugList(dl.getDrugsByLabel(calculateBean.getDrugName())); logFile.debug("Getting major classifications.");

    So... the logfile could contain:

    Getting particular drug information. NullPointerException at line N

    Clearly more logging needs to be added, so you can tell which variable is null after the fact.

  • AlexC (unregistered)

    I do hate it when people come on and defend mad practices in coding but I once had to fix a piece of problem code existed in a routine that, when run in a debugging tool (I don't want to say which one), would crash and die horribly. I spent some really long hours trying to fix the issue and then as a last gasp attempt I just ran it outside the debugger it worked perfectly. I was stung by that and it stayed with me to never trust debuggers 100%. However, obviously this code should never, ever make it to a production build.

  • (cs)

    I'd like to say I've never seen quite that degree of logging abuse before. Yep. I sure would like to be able to say that. sigh

  • (cs)

    I have logged your error, pray get off mommy and daddy's wooden table.

    I might hazard a guess that the log function will read a "Save stuff" option. I've done similar for remote assistance with an app. "It doesn't work." "Be more specific?" "It errors" "Gah. Run THIS version. Send us log." Everything they were doing wrote out, though not quite every single line being logged.

  • SD (unregistered) in reply to nitehawk

    gerontocracy is the word.

  • dave (unregistered)

    this is not what you mean: "meritocracy" this is what you mean: "gerontocracy"

    further information: http://en.wikipedia.org/wiki/Gerontocracy

  • Two (unregistered)

    We had Pokemon exception handling ... now Pokemon logging ... are we creating a meme here?

  • (cs)

    Just as an aside, I always hate it when I see this in a coworker's code:

    1. Put some code into a logging statement that affects the current state, eg: Log.debug(x++);
    2. Does some super expensive function call just to generate a log statement, without bothering to check if logging is enabled, eg: Log.debug(xpathExpression.evaluate(hugeDOMDoc));
  • Bus Logic (unregistered) in reply to nitehawk
    nitehawk:
    In fact in my career I would say I get brow beat due to my age without regard to my experience. (10 years industry experience at 29). Then when I do get to an age where I can perform the same, I get scoffed because of the low amount of time at the company.
    That's funny, I'm also 29 years old with 10 years industry experience; the only difference is that I'm a senior developer and a team lead. Maybe it's not your age that's the problem? No offence meant by that, I just mean maybe you're working for a crappy company that doesn't recognise your talent?
  • (cs) in reply to Konrads
    Konrads:
    logFile.info("Did XYZ"); logFile.debug("Just invoked logging function with arguments: \"logFile.info(\"Did XYZ\"); \""); logFile.debug("Just invoked logging function with arguments: \"Just invoked logging function with arguments: \"logFile.info(\"Did XYZ\"); \"\");

    ...

    For consistency, I hope he's dealt with the case of debugging errors inside logFile.debug()?

  • Derp (unregistered)

    Half expected to see: logFile.debug("Reticulating Splines.");

  • (cs)

    This is brillant!! You accomplish debugging, logging and commenting all in one step. Truly a revolutionary approach.

  • Matt Westwood (unregistered) in reply to qbolec
    qbolec:
    Actually it might be a good idea, to have logger plugged everywhere throughout the code as long as you have a nice way to turn it on/off, preferably at a module level granularity, when the interpreter is so slow that the impact is negligible anyway. In compiled languages you usually have preprocessor and thus can define log(x) to do nothing. But then you can not just turn it on/off on production. I can imagine some crazy way to force JITed languages to change implementation of log(x) on fly. Since I can, then probably it is already built in into .NET or something. But then again, I think it would be much better to have just a Trace mechanism built in into the interpreter/runtime environment/ or just a debugger, so that the developer doesn't have to echo each line of code to log(x).

    I found, that Math has a log function, but it doesn't do what I need, though.

    With log4j (which this looks like) you can set it so that you can change the log level and not bounce the app.

    All you need to do is run at info level or coarser and your debug level logs won't appear.

    At least (generally speaking) the logs are informative. I've just been clearing out messages that say just "Entering loop" in every iteration of a many-thousand-times-executed loop and cut the execution time by more than half.

    Seen enough worse stuff than this to opine "Not a WTF", just a bit unwieldy and inflexible. If you find yourself working in a regime that insists on it, though, all I can suggest is: that's what Monster's for.

  • SR (unregistered) in reply to Anonymous
    Anonymous:
    How is he going to log the inevitable "disk full" error?

    By logging it! Didn't you read the article?

    Oh, hang on...

  • evertras (unregistered)

    I have to admit I did something exactly like this just recently. The reasoning for it was that there was a bug on a client's machine in Canada that I couldn't reproduce for the life of me. Turns out it was specific to his environment, and it was crashing in such a strange place that I wouldn't have found it if I hadn't done SuperLogging. Fixed! Definitely, definitely not something to do on a regular basis, but hey, it saved me.

    And seriously, no "yo dawg, I heard you liked logging" jokes yet? I'm ashamed.

    captcha: minim, the minimal spelling of minimum.

  • Anonymous (unregistered) in reply to AlexC
    AlexC:
    I do hate it when people come on and defend mad practices in coding but I once had to fix a piece of problem code existed in a routine that, when run in a debugging tool (I don't want to say which one), would crash and die horribly. I spent some really long hours trying to fix the issue and then as a last gasp attempt I just ran it outside the debugger it worked perfectly. I was stung by that and it stayed with me to never trust debuggers 100%. However, obviously this code should never, ever make it to a production build.
    It's a lesson that everyone learns eventually, but it doesn't mean that debuggers aren't your friend. It's a plain fact that execution under a debugger is subtly different to execution without a debugger, so you have to understand that very occasionally you'll see different behaviour with the debugger attached. But it's incredibly rare so you just need to be mindful of it and test outside a debugger if you think something fishy is going on. Otherwise, the debugger is a coder's best friend and you certainly shouldn't slight it due to those very rare cases of unpredictable behaviour. Overall you'll be a far less productive coder if you favour logging over debugging.
  • Darth MS (unregistered)

    At least those are all debug statements. We had a developer who was similarly (but not quite to that degree) overzealous about logging, and since the debug statements didn't show up in certain circumstances (when running from NetBeans IDE - though that is easily fixable by changing the log config files) they put everything in info (or warn or error there was a problem), including the beginning and end of all method calls.

  • davee123 (unregistered)

    It's better than bad, it's good!

    DaveE

  • notme (unregistered) in reply to Inigo Montoya
    Inigo Montoya:
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    I think he knows very well what that word means and was being sarcastic.

  • (cs)
    Alex Papadimoulis:
    ...debugging allows you to step-through currently executing code and get a “behind the scenes” view of the environment...
    It's a shame that the "step-through" method has become interchangeable with Debugging in general; it's just one of many methods for debugging. Maybe I feel that way because I so rarely use the "step-through" method myself.

    Another great debugging method is the use of trace statements. However, this article takes that to the extreme, since the messages featured here basically reproduce the code's documentation every time it's executed. I just hope that the logFile has more than one "log level" (as it appears to), and enough sense to throw out anything below the defined log level. Still, even if it did it sounds like Christophe was so freakin' stupid he was running it at the "debug" log level in production*.

    • Yes, I believe it, since I've seen this happen before** (with messages as dense or more-so than those featured here).

    ** No, the log files were not of any use to anyone.

  • cappeca (unregistered)

    I don't see the WTF here, as long as it's temporary, has a Log/No log switch, and helped find bugs. If you have to do that in order to have a robust production system in the end, do it.

  • (cs) in reply to hatterson
    hatterson:
    This is brillant!! You accomplish debugging, logging and commenting all in one step. Truly a revolutionary approach.

    Now all we need to do is invent a log-to-bytecode compiler, and we can do away with the code itself altogether!

  • (cs)

    TRWTF is that he chose to clutter up the source code with all this logging code, when he could have just hacked the compiler to log a copy of each line of source any time the corresponding bytecode is executed.

  • (cs) in reply to qbolec
    qbolec:
    I found, that Math has a log function, but it doesn't do what I need, though.
    It probably only works if you're logging math errors.
  • Ian (unregistered) in reply to Inigo Montoya
    Inigo Montoya:

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    Inconceivable!

  • random internet wanker (unregistered)

    Setting aside the "diarrhea" aspect of this technique, the grouping would bug the hell out of me. If you're going to log something about your code, don't put that log statement with the previous piece of code. That's like putting the first sentence of each paragraph at the end of the previous paragraph.

    In our codebase, it's also one way in which comments get orphaned or not updated when the portion of code they refer to is changed. In my mind this grouping hinders the clarity of your intentions just as much as having 400 of these logging statements scattered throughout your code. yuck.

  • Inigo Montoya (unregistered) in reply to notme
    notme:
    Inigo Montoya:
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    I think he knows very well what that word means and was being sarcastic.

    To show that you're using a word ironically, you put it in quotes.

  • Anonymous (unregistered) in reply to Inigo Montoya
    Inigo Montoya:
    notme:
    Inigo Montoya:
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    I think he knows very well what that word means and was being sarcastic.

    To show that you're using a word ironically, you put it in quotes.
    Where the hell did you learn English? I'd like to see a citation for that. I understood perfectly well he was being sarcastic, quotes would have just been dumb in that context. I hate it when people "feel" that thay "have" to "quote" "everything". It ruins the flow of the writing.

Leave a comment on “Log Everything”

Log In or post as a guest

Replying to comment #:

« Return to Article