*', '>=*', '<*', '<=*' - compare $reqValue * examples: * - show when $_REQUEST['DBG_SCH'] == '1' * DBG::_('DBG_SCH', '1', "fieldsConfig({$idTable})", $fieldsConfig, __CLASS__, __FUNCTION__, __LINE__); * - show when $_REQUEST['DBG_SCH'] > '1' * DBG::_('DBG_SCH', '>1', "fieldsConfig({$idTable})", $fieldsConfig, __CLASS__, __FUNCTION__, __LINE__); * - show when any value: strlen($_REQUEST['DBG_SCH']) > 0 * DBG::_('DBG_SCH', true, "fieldsConfig({$idTable})", $fieldsConfig, __CLASS__, __FUNCTION__, __LINE__); * - always show * DBG::_(true, true, "fieldsConfig({$idTable})", $fieldsConfig, __CLASS__, __FUNCTION__, __LINE__); */ public static function _($reqKey, $reqValueExpr, $label, $variable, $className, $functionName, $lineNumber, $borderColor = 'red') { if (!DBG::isActive()) return; $showDBG = false; $reqValue = (true === $reqKey || !$reqKey)? '' : V::get($reqKey, '', $_GET); if (true === $reqKey) { $showDBG = true; } else if (strlen($reqValue) == 0) { return; } else if ($reqValue == $reqValueExpr) { $showDBG = true; } else if (true === $reqValueExpr) { $showDBG = true; } else { if ('>=' == substr($reqValueExpr, 0, 2)) { if ($reqValue >= substr($reqValueExpr, 2)) { $showDBG = true; } } else if ('>' == substr($reqValueExpr, 0, 1)) { if ($reqValue > substr($reqValueExpr, 1)) { $showDBG = true; } } else if ('<=' == substr($reqValueExpr, 0, 2)) { if ($reqValue <= substr($reqValueExpr, 2)) { $showDBG = true; } } else if ('<' == substr($reqValueExpr, 0, 1)) { if ($reqValue < substr($reqValueExpr, 1)) { $showDBG = true; } } else { if ($reqValue = $reqValueExpr) { $showDBG = true; } } } if ($showDBG) { ?>
| Lp. | $prefixes) : ?> | |
|---|---|---|
| $prefixes) : ?> |
: ""
: ""
|
' . $outLines . '' . "\n"; } /** * @param $mixedArg string or Exception */ public static function log($mixedArg, $type = '', $msg = '') { if (!self::isActive()) return; if ('Debug' == V::get('_route', '', $_REQUEST) && !V::get('DBG', '', $_REQUEST)) return; static $_firstRun = true; if ($_firstRun) { $_firstRun = false; self::_log([ 'msg' => V::get('REQUEST_METHOD', '', $_SERVER) . " " . V::get('REQUEST_URI', '', $_SERVER), 'POST' => $_POST, 'GET' => $_GET, ]); } self::_log($mixedArg, $type, $msg); } public static function _log($mixedArg, $type = '', $msg = '') { // * TODO: debug to file based on session_id (/tmp/se-debug-{$date("Y-m-d")}-{$login}_{$ip}_{$session_id}.log) $logInfo = [ 'date' => date("Y-m-d H:i:s"), 'type' => $type, 'msg' => $msg, 'log' => '', 'trace' => '', ]; if ($mixedArg instanceof Exception) { $logInfo['type'] = 'Exception'; if (!empty($logInfo['msg'])) $logInfo['msg'] .= ". "; $logInfo['msg'] .= $mixedArg->getMessage(); $logInfo['log'] = [ 'code' => $mixedArg->getCode(), 'line' => $mixedArg->getLine(), 'file' => str_replace(APP_PATH_ROOT, 'SE', $mixedArg->getFile()), ]; $logInfo['trace'] = $mixedArg->getTraceAsString();// getTrace } else if (is_string($mixedArg)) { if ('sql' == $type) { if (!$logInfo['type']) $logInfo['type'] = 'sql'; if (empty($logInfo['msg'])) $logInfo['msg'] = "sql"; $logInfo['log'] = $mixedArg; } else { if (empty($logInfo['type'])) $logInfo['type'] = 'string'; $logInfo['msg'] = $mixedArg; $logInfo['log'] = ''; } ob_start(); debug_print_backtrace(); $logInfo['trace'] = ob_get_clean(); } else if ('array' == $type || is_array($mixedArg)) { $mixedArg = (array)$mixedArg; if (!$logInfo['type']) $logInfo['type'] = 'array'; if (!empty($logInfo['msg']) && !empty($mixedArg['msg'])) $logInfo['msg'] .= ". {$mixedArg['msg']}"; else if (empty($logInfo['msg']) && !empty($mixedArg['msg'])) $logInfo['msg'] = $mixedArg['msg']; if (!empty($mixedArg['msg'])) unset($mixedArg['msg']); $logInfo['log'] = $mixedArg; ob_start(); debug_print_backtrace(); $logInfo['trace'] = ob_get_clean(); } $logInfo['trace'] = str_replace(APP_PATH_ROOT, 'SE', $logInfo['trace']); $logInfo['trace'] .= (("\n" == substr($logInfo['trace'], -1)) ? '' : "\n") . "URI: " . V::get('REQUEST_URI', '', $_SERVER); if (!$logInfo['type']) $logInfo['type'] = 'unknown'; error_log( json_encode($logInfo) . "\n" , 3 , '/tmp/se-debug-' . implode('-', [ date("Y-m-d"), User::getLogin(), Request::getUserIp(), substr(session_id(), 0, 6), V::get('REQUEST_TIME', '', $_SERVER)// [REQUEST_TIME] => 1485770466 ]) . '.log' ); } }