Note that there are some explanatory texts on larger screens.

plurals
  1. POWhich file path and line number to show in log?
    text
    copied!<p>I have written a <a href="https://github.com/codealchemy/Log" rel="nofollow">logging library</a> that will add entries to a file or output stream.</p> <p>When the entry is added to the log, it also includes context information such as the file and line number of the call that was made to add the entry.</p> <p>My question is: Should I use the file path and line number of the call that added the entry, or the caller that triggered the event to log the message?</p> <h1>trigger.php:</h1> <pre><code>&lt;?php $do-&gt;something(); #line 2 </code></pre> <h1>do.php</h1> <pre><code>&lt;?php class Do { public function something () { $this-&gt;log-&gt;add('Did something.', E_USER_NOTICE); # line 6 } } </code></pre> <p>Right now, the message "Did something." is logged as having come from do.php line 6. Is it better to change the logging class to say that the message came from trigger.php line 2?</p> <p><strong>EDIT</strong></p> <p>Clarifying a few things.</p> <ol> <li>The library includes the whole call stack in the log entry. So in more feature rich logging classes, you can see a lot more than what the example above entails.</li> <li>The library does make use of logging levels and will filter out levels that aren't needed. The example above does not show that, but you can look at the library itself to know for sure.</li> </ol> <p>Unfortunately I wasn't clear on how the message is being represented in this one scenario. This very minor scenario will only show one file path and one line. <strong>Assuming this could not be changed</strong>, which file path and line number would be logged?</p> <p>Thank you for your help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload