Like if I’m using print statements to test my code. Is it okay to leave stuff like that in there when “publishing” the app/program?

Edit: So I meant logging. Not “tests”. Using console.log to see if the code is flowing properly. I’ll study up on debugging. Also, based on what I managed to grasp from your very helpful comments, it is not okay to do, but the severity of how much of an issue it is depends on the context? Either that or it’s completely avoidable in the first place if I just use “automated testing” or “loggers”.

  • brian
    link
    fedilink
    arrow-up
    5
    ·
    14 days ago

    my team was driving me insane with leaving console.log("here") all over the place in every pr, so now we have a “no console.log” eslint rule in ci.

    I guess my answer is it depends on your team. good logs are different, but imo if they’re just debugging statements they shouldn’t even make it into the repo let alone prod.

    if it’s just you, do whatever you want lol, performance is almost certainly not significant and most users should end up ignoring them anyway

    • dave@feddit.uk
      link
      fedilink
      English
      arrow-up
      1
      ·
      14 days ago

      (Guessing JS / TS) I look after a moderately sized app, and still find console.log() useful sometimes. They are all protected by a Boolean, so we have authLog && console.log('something about auth') and the bools are all set in one global file. So turning debug logging on and off is very simple.

      The best thing is that when it’s off, the bundler strips all the console log lines from the source, so they’re not even there-but-inactive in production.