Customize error log of PHP for WordPress debugging

Questo articolo รจ stato scritto oltre 1 years, il contenuto potrebbe essere datato.

Start with a case example:

  • Errors on the log that reference functions.php or hook stuff from core
  • You cannot find the original method causing the issue
  • This error happen on production
  • You cannot find on production (without replicating and investigating) but you don’t know the URL (that cause the issue) or why it is happening

My idea was to create a plugin that I put on mu-plugins so is automatically enabled and not create issue on production.

Also that the log from the server contain the URL and the filter where is happening the error.

An example of output:

(
    [error] => Notice
    [file] => /home/domain/wp-includes/functions.php
    [line] => 4146
    [context] => Array ()
    [url] => https://domain/author/user/
    [filter] => pre_get_posts
    [message] => Notice (8): is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) 
)

Code: https://gist.github.com/Mte90/e09a84a4e1c61690e55b3a6e0c67ef94

An example of reporting: https://github.com/gocodebox/lifterlms/issues/408

We cannot forget also the support for Query-Monitor that this snippet contain ๐Ÿ˜€

Liked it? Take a second to support Mte90 on Patreon!

Leave a Reply

Your email address will not be published. Required fields are marked *