title: Logging best practice - log method call or log at beginning of a target method?
body: <p>When should we log? Before function calls (example A) or at beginning of a target method (example B)?</p>
  
  <p>Note, that this question is about exact logger function call placement, not general best logging practices.</p>
  
  <p><strong>Solution A: Log at function call</strong>:</p>
  
  <pre><code>function someProcess() {
      log.info("Reading data");
      readDataFromIO();
      log.info("Outputing data");
      outputDataToScreen();
  }
  
  // ... other module:
  
  function readDataFromIO() {
      ...
  }
  
  function outputDataToScreen() {
      ... 
  }
  </code></pre>
  
  <p><strong>Solution B: Log at the beggining of a method</strong>:</p>
  
  <pre><code>function someProcess() {
      readDataFromIO();
      outputDataToScreen();
  }
  
  // ... other module:
  
  function readDataFromIO() {
      log.info("Reading data");
      ...
  }
  
  function outputDataToScreen() {
      log.info("Outputing data");
      ... 
  }
  </code></pre>
  
  <p>In solution A you can customize message or resign of logging when efficiency issues rise, but you can just forget to log and you have lot of duplicated code if the log message looks the same. In solution B there is no risk to forget about logging and no code duplication, but you can't turn off logging logic 100%, and you are in trouble if an error is in a method call, like a null pointer exception. <strong>Which is the best practice?</strong></p>