Create a logging system

0

Well the standard php logging system does not meet 100%.

I want to know if there is any way of when an error occurs in php, I need to save a log and some values that are in some variables.

I already know how to create and write the txt file, what do I need and how to identify that an error occurred in php?

    
asked by anonymous 13.12.2016 / 18:09

1 answer

0

You can do this by extending the PHP Exception class

Example usage:

<?php

class customException extends Exception
  {
  public function errorMessage()
    {
    //error message
    $errorMsg = 'Erro na linha '.$this->getLine().' do arquivo '.$this->getFile()
    .': <b>'.$this->getMessage().'</b>';
    return $errorMsg;
    }
  }
    
14.12.2016 / 20:46