0
How do I make so that every time an error occurs on my site, I can write in the log the way I set ?
I am working with wordpress so I am 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 mistake :
<?php pg_connect();
$a+=5;?>
But it doesn’t write in the log the way I’d like, apparently it follows the php pattern and I’d 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".
Do you want to change the way PHP sends errors or do you want to send custom errors as well? Or both?
– Ricardo BRGWeb
If possible I want to send customizable errors, I am with site in production and can not identify which pages are giving error. By the amount of pages and files I can’t download the site to search where errors occur, so I wanted to edit the log so it returns the information I ask for.
– Kaue Alves