method logError documentation in bbn\X

Puts the PHP errors into a JSON file.

function($errno, $errstr, $errfile, $errline) { if (\defined('BBN_DATA_PATH') && is_dir(BBN_DATA_PATH.'logs')) { $file = BBN_DATA_PATH.'logs/_php_error.json'; $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 20); foreach ($backtrace as &$b) { if (!empty($b['file'])) { $b['file'] = str_replace(BBN_APP_PATH, '', $b['file']); } } $r = false; if (is_file($file)) { $r = json_decode(file_get_contents($file), 1); } if (!$r) { $r = []; } $t = date('Y-m-d H:i:s'); if (class_exists('\\bbn\\Mvc')) { $mvc = Mvc::getInstance(); } $errfile = str_replace(BBN_APP_PATH, '', $errfile); $idx = self::find( $r, [ 'type' => $errno, 'error' => $errstr, 'file' => $errfile, 'line' => $errline, 'request' => '' ] ); if ($idx !== null) { $r[$idx]['count']++; $r[$idx]['last_date'] = $t; $r[$idx]['backtrace'] = $backtrace; } else{ $r[] = [ 'first_date' => $t, 'last_date' => $t, 'count' => 1, 'type' => $errno, 'error' => $errstr, 'file' => $errfile, 'line' => $errline, 'backtrace' => $backtrace, 'request' => '' //'context' => $context ]; } self::sortBy($r, 'last_date', 'DESC'); file_put_contents($file, Json_encode($r, JSON_PRETTY_PRINT)); } }

Puts the PHP errors into a JSON file. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.