/*! error handler, put normal php errors in log file

@param errn
error number
@param errstr
error description
@param file
error file
@param line
error line
@param context
error cntext
766318
public static function error_log($errn,$errstr,$file,$line,$context){
		LogMaster::log($errstr." at ".$file." line ".$line);
	}
1301279
public static function __error($message = 'View error', $file = null, $line = null)
    {
        if (!is_null($file)) {
            $message .= sprintf(' in file "%s"', $file);
            if (!is_null($line)) {
                $message .= sprintf(' at line %s', $line);
            }
        }
        trigger_error($message, E_USER_WARNING);
    }
576276
function errorHandler( $errno, $errstr, $errfile, $errline )
    {
        if ( error_reporting() == 0 ) // @ error-control operator is used
            return;
        if ( !eZDebug::isDebugEnabled() )
            return;
        $str = "$errstr in $errfile on line $errline";
        if ( empty( $GLOBALS['eZDebugPHPErrorNames'] ) )
        {
            $GLOBALS['eZDebugPHPErrorNames'] =
                array( E_ERROR => 'E_ERROR',
                       E_PARSE => 'E_PARSE',
                       E_CORE_ERROR => 'E_CORE_ERROR',
                       E_COMPILE_ERROR => 'E_COMPILE_ERROR',
                       E_USER_ERROR => 'E_USER_ERROR',
                       E_WARNING => 'E_WARNING',
                       E_CORE_WARNING => 'E_CORE_WARNING',
                       E_COMPILE_WARNING => 'E_COMPILE_WARNING',
                       E_USER_WARNING => 'E_USER_WARNING',
                       E_NOTICE => 'E_NOTICE',
                       E_USER_NOTICE => 'E_USER_NOTICE',
                       E_STRICT => 'E_STRICT' );
            // Since PHP 5.2
            if ( defined('E_RECOVERABLE_ERROR') )
                $GLOBALS['eZDebugPHPErrorNames'][E_RECOVERABLE_ERROR] = 'E_RECOVERABLE_ERROR';
            // Since PHP 5.3
            if ( defined('E_DEPRECATED') )
                $GLOBALS['eZDebugPHPErrorNames'][E_DEPRECATED] = 'E_DEPRECATED';
            if ( defined('E_USER_DEPRECATED') )
                $GLOBALS['eZDebugPHPErrorNames'][E_USER_DEPRECATED] = 'E_USER_DEPRECATED';

        }
        $errname = "Unknown error code ($errno)";
        if ( isset( $GLOBALS['eZDebugPHPErrorNames'][$errno] ) )
        {
            $errname = $GLOBALS['eZDebugPHPErrorNames'][$errno];
        }
        switch ( $errname )
        {
            case 'E_ERROR':
            case 'E_PARSE':
            case 'E_CORE_ERROR':
            case 'E_COMPILE_ERROR':
            case 'E_USER_ERROR':
            case 'E_RECOVERABLE_ERROR':
            {
                $this->writeError( $str, 'PHP: ' . $errname );
            } break;

            case 'E_WARNING':
            case 'E_CORE_WARNING':
            case 'E_COMPILE_WARNING':
            case 'E_USER_WARNING':
            case 'E_DEPRECATED':
            case 'E_USER_DEPRECATED':
            {
                $this->writeWarning( $str, 'PHP: ' . $errname );
            } break;

            case 'E_NOTICE':
            case 'E_USER_NOTICE':
            {
                $this->writeNotice( $str, 'PHP: ' . $errname );
            } break;

            case 'E_STRICT':
            {
                return $this->writeStrict( $str, 'PHP: ' . $errname );
            } break;
            default:
            {
                 $this->writeError( $str, 'PHP: ' . $errname );
            } break;
        }
    }
146258
protected function _loadFileErrorHandler($errno, $errstr, $errfile, $errline)
    {
        if ($this->_loadFileErrorStr === null) {
            $this->_loadFileErrorStr = $errstr;
        } else {
            $this->_loadFileErrorStr .= (PHP_EOL . $errstr);
        }
    }
1124829
public static function onError( $code, $message, $file = null, $line = null, $context = null )
    {
        $_trace = \debug_backtrace();
        $_traceText = static::_cleanTrace( $_trace, 3 );

        if ( E_NOTICE == $code )
        {
            //return false;
        }

        static::$_error = array(
            'code'       => $code,
            'type'       => null,
            'message'    => $message,
            'file'       => $file,
            'line'       => $line,
            'trace'      => $_traceText,
            'traces'     => $_trace,
            'source'     => static::_getCodeLines( $file, $line, static::$_sourceLines ),
            'start_line' => static::$_startLine,
        );

        Log::error( static::$_error['message'] . ' (' . static::$_error['code'] . ')' );

        return static::renderError();
    }
268259
public function handler($errno, $errstr, $errfile, $errline)
    {
        throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
    }
708673
public function addError($error, $file = __FILE__, $line = __LINE__, $type = ERROR_INFORMATION, $log = LOG_SYSTEM) {
        if ($log != LOG_HISTORY && $log != LOG_CRONS && $log != LOG_EVENT) {
            if (Config::config()['user']['debug']['log']) {
                if ($log == LOG_SQL) {
                    $error = preg_replace('#([\t]{2,})#isU', "", $error);
                }

                $data = date("d/m/Y H:i:s : ", time()) . '[' . $type . '] file ' . $file . ' / line ' . $line . ' / ' . $error;
                file_put_contents(APP_LOG_PATH . $log . '.log', $data . "\n", FILE_APPEND | LOCK_EX);

                if ((Config::config()['user']['debug']['error']['error'] && $type == ERROR_FATAL) || (Config::config()['user']['debug']['error']['exception'] == true && $type == ERROR_EXCEPTION) || preg_match('#Exception#isU', $type) || (Config::config()['user']['debug']['error']['fatal'] == true && $type == ERROR_ERROR)) {
                    if (CONSOLE_ENABLED == MODE_HTTP) {
                        echo $data . "\n<br />";
                    }
                    else {
                        echo $data . "\n";
                    }
                }
            }
        }
        else {
            file_put_contents(APP_LOG_PATH . $log . '.log', $error . "\n", FILE_APPEND | LOCK_EX);
        }
    }
661968
private function catchWarning($errno, $errstr, $errfile, $errline)
    {
        $this->setError(array(
            'error' => "Connecting to the POP3 server raised a PHP warning: ",
            'errno' => $errno,
            'errstr' => $errstr,
            'errfile' => $errfile,
            'errline' => $errline
        ));
    }
226345
public static function error_handler($errno, $errstr, $errfile, $errline)
    {
        self::flush(true);

        $response = PheryResponse::factory()->exception($errstr, array(
            'code' => $errno,
            'file' => self::$expose_paths ? $errfile : pathinfo($errfile, PATHINFO_BASENAME),
            'line' => $errline
        ));

        self::respond($response);
        self::shutdown_handler(false, true);
    }
549386
public static function error($number, $string, $file, $line)
    {
        throw new \ErrorException($string, 0, $number, $file, $line);
    }
399858
public static function handleError($errno, $errstr, $errfile, $errline, $errcontext, $isException = false)
    {
        $error = array(
            'number' => $errno,
            'desc' => $errstr,
            'file' => $errfile,
            'line' => $errline,
            'context' => $errcontext,
            'isException' => $isException,
        );
        $handled = false;
        if ($isException) {
            $handled = static::call(get_class($errcontext), $handled);
        }
        if (!$handled) {
            static::$errors[] = $error;
        }
    }
274226
public function phpErrorHandler($errno, $errstr, $errfile, $errline) {
		foreach($this->ignoreDirs as $dir) {
			if(strpos($errfile, $dir) === 0)
				return;
		}

		if($this->isLogging() && $this->logPHPErrors)
			$this->log(\Psr\Log\LogLevel::NOTICE, 'PHP ('.static::getPHPError($errno).'): '.$errstr, $errfile, $errline);
		throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
	}
185041
public function on_error( $num, $str, $file, $line, $context = NULL ) {

		$log_context = [];
		if ( $context ) {
			$skip_keys   = array_merge( array_keys( $GLOBALS ), self::$super_globals_keys );
			$skip        = array_fill_keys( $skip_keys, '' );
			$log_context = array_filter( array_diff_key( (array) $context, $skip ) );
		}

		$log_context[ 'file' ] = $file;
		$log_context[ 'line' ] = $line;

		// Log the PHP error.
		do_action(
			\Inpsyde\Wonolog\LOG,
			new Log( $str, self::$errors_level_map[ $num ], Channels::PHP_ERROR, $log_context )
		);

		return FALSE;
	}
182244
public function error($code, $message, $file, $line)
    {
        if ($code && error_reporting()) {
            if (X_DEBUG && PHP_SAPI !='cli') {
                $error = self::getComponent('errorHandler');
                $error->displayError($code, $message, $file, $line);
            } else if(PHP_SAPI =='cli'){
                echo $message;
            }else {
                $errorCallBack = \X\Router::$error_callback;
                if ($errorCallBack) {
                    call_user_func($errorCallBack, ['message' => $message, 'file' => $file, 'line' => $line]);
                    exit;
                } else {
                    echo '<fieldset style="background: #F3F3F3">';
                    echo '<legend style="color:red;">error[' . $code . ']</legend>';
                    echo '<p>' . $message . '  (' . $file . '[' . $line . '])</p>';
                    echo '</fieldset>';

                    echo '<fieldset style="background: #ddd;">';
                    echo '<legend style="color:#800000">trace</legend>';
                    echo '<pre>';
                    debug_print_backtrace();
                    echo '</pre>';
                    echo '</fieldset>';
                }
            }
        }
    }
668787
public static function addError($errno, $errstr = '', $errfile = '', $errline = 0)
    {
        $stack = & static::$stack[count(static::$stack) - 1];
        $stack = new ErrorException($errstr, 0, $errno, $errfile, $errline, $stack);
    }
590497
static function handleError($errstr, $type = E_USER_ERROR)
    {
        self::set("errors", true);

        trigger_error($errstr, $type);
    }
458906
public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
    {
        // Don't throw exception if error reporting is switched off
        if (error_reporting() == 0) {
            return;
        }
        // Only throw exceptions for errors we are asking for
        if (error_reporting() & $errno) {

            $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline);
            if ($this->throwErrorExceptions) {
                throw $exception;
            } else {
                $this->fb($exception);
            }
        }
    }