Error handling - WordPress

0

How do I do that every time an error occurs on my site, I can write to the log the way I define it?

I'm working with wordpress so I'm trying to make a plugin that does this, I tried to use the mu-plugins and add this code:

<?php


/**
 Plugin Name: TESTE
 Description: testando log novo
 Version: 1.0
 Author: Vteste
Author URI: teste

-------
LICENSE: teste
   **/ 

function trataErros($errno, $errstr, $errfile, $errline)
{
    $string = "$errno - $errstr em $errfile na linha $errline\n";
    file_put_contents('error.log', $string, FILE_APPEND);
    // se retornar TRUE não faz o tratamento padrão do erro no PHP
    return TRUE;
}
set_error_handler('trataErros');

?>

And force this error:

<?php pg_connect();
$a+=5;?>

But it does not write in the log the way I like it, apparently it follows the php pattern and I would like to change it.

I have to make my log look like this:

[08-Jun-2017 22:15:25 America/Los_Angeles] PHP Notice:  Undefined index: k in D:\h\s\w\wp\t\l\r\m\l.php on line 8 - "Minha mensagem adicional".
    
asked by anonymous 09.06.2017 / 19:14

0 answers