|
@@ -264,38 +264,54 @@ class Route_Debug extends RouteBase {
|
|
|
UI::gora();
|
|
UI::gora();
|
|
|
// UI::menu();
|
|
// UI::menu();
|
|
|
UI::setTitle("Debug");
|
|
UI::setTitle("Debug");
|
|
|
- echo UI::h('div', ['class'=>'container', 'style'=>'position:fixed; top:0; left:0; background-color:#ddd; padding:3px; width:100%'], [
|
|
|
|
|
- UI::h('a', ['href'=>$this->getLink()], "wróć"),
|
|
|
|
|
- UI::h('span', ['style'=>'padding:0 6px'], "|"),
|
|
|
|
|
- UI::h('span', ['class' => 'label label-'.(DBG::isActive() ? "success" : "danger")], "(Debug - " . (DBG::isActive() ? "włączony" : "wyłączony") . ") "),
|
|
|
|
|
- UI::h('span', ['style'=>'padding:0 6px'], "|"),
|
|
|
|
|
- UI::h('button', ['onClick'=>'location.reload()', 'class'=>"btn btn-xs btn-default"], "odśwież"),
|
|
|
|
|
- ]);
|
|
|
|
|
try {
|
|
try {
|
|
|
$filerUser = V::get('user', '', $_REQUEST);// TODO: show another user debug
|
|
$filerUser = V::get('user', '', $_REQUEST);// TODO: show another user debug
|
|
|
$logName = V::get('name', '', $_REQUEST);
|
|
$logName = V::get('name', '', $_REQUEST);
|
|
|
|
|
+ $uiWarning = null;
|
|
|
|
|
+ $uiLogFiles = null;
|
|
|
if (!$logName) {
|
|
if (!$logName) {
|
|
|
$today = date("Y-m-d");
|
|
$today = date("Y-m-d");
|
|
|
$cmd = "ls -1rt {$this->logPathPrefix}se-debug-{$today}-*.log | tail -5";
|
|
$cmd = "ls -1rt {$this->logPathPrefix}se-debug-{$today}-*.log | tail -5";
|
|
|
V::exec($cmd, $out, $ret);
|
|
V::exec($cmd, $out, $ret);
|
|
|
if (empty($out)) {
|
|
if (empty($out)) {
|
|
|
- UI::alert('warning', "No logs today. Searching previous...");
|
|
|
|
|
|
|
+ $uiWarning = "No logs today. Searching previous...";
|
|
|
$cmd = "ls -1rt {$this->logPathPrefix}se-debug-*.log | tail -5";
|
|
$cmd = "ls -1rt {$this->logPathPrefix}se-debug-*.log | tail -5";
|
|
|
V::exec($cmd, $out, $ret);
|
|
V::exec($cmd, $out, $ret);
|
|
|
- if (empty($out)) throw new Exception("Log files not found");
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!empty($out)) {
|
|
|
|
|
+ $uiLogFiles = [ 'ret' => $ret, 'cmd' => $cmd, 'out' => $out ];
|
|
|
|
|
+ $logName = end($out);// /tmp/se-debug-2017-01-30-plabudda-192.168.61.206-4qqrd0-1485775975.log
|
|
|
|
|
+ {
|
|
|
|
|
+ if ("{$this->logPathPrefix}se-debug-" != substr($logName, 0, strlen("{$this->logPathPrefix}se-debug-"))) throw new Exception("Wrong log name prefix");
|
|
|
|
|
+ if ('.log' != substr($logName, -1 * strlen('.log'))) throw new Exception("Wrong log name suffix");
|
|
|
|
|
+ $logName = substr($logName, strlen("{$this->logPathPrefix}se-debug-"), -1 * strlen('.log'));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ echo UI::h('div', ['class'=>'container', 'style'=>'position:fixed; top:0; left:0; background-color:#ddd; padding:3px; width:100%'], [
|
|
|
|
|
+ UI::h('a', ['href'=>$this->getLink()], "wróć"),
|
|
|
|
|
+ UI::h('span', ['style'=>'padding:0 6px'], "|"),
|
|
|
|
|
+ UI::h('span', ['class' => 'label label-'.(DBG::isActive() ? "success" : "danger")], "(Debug - " . (DBG::isActive() ? "włączony" : "wyłączony") . ") "),
|
|
|
|
|
+ UI::h('span', ['style'=>'padding:0 6px'], "|"),
|
|
|
|
|
+ UI::h('button', ['onClick'=>'location.reload()', 'class'=>"btn btn-xs btn-default"], "odśwież"),
|
|
|
|
|
+ ($logName) ? UI::h('span', ['style'=>'padding:0 6px'], "|") : '',
|
|
|
|
|
+ ($logName)
|
|
|
|
|
+ ? UI::h('a', ['target'=>"_blank", 'href'=>$this->getLink('viewLog', ['name'=>$logName]), 'class'=>"btn btn-xs btn-default"], [
|
|
|
|
|
+ "otwórz w nowym oknie ",
|
|
|
|
|
+ UI::h('i', ['class'=>'glyphicon glyphicon-new-window']),
|
|
|
|
|
+ ])
|
|
|
|
|
+ : '',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ echo UI::h('div', ['style'=>'height:32px']);
|
|
|
|
|
+ if ($uiWarning) UI::alert('warning', $uiWarning);
|
|
|
|
|
+ if (!$logName && null === $uiLogFiles) throw new Exception("Log files not found");
|
|
|
|
|
+ if (null !== $uiLogFiles) {
|
|
|
echo UI::h('div', ['class'=>"alert alert-info"], [
|
|
echo UI::h('div', ['class'=>"alert alert-info"], [
|
|
|
"Last log files",
|
|
"Last log files",
|
|
|
- " (return code: {$ret})",
|
|
|
|
|
- "<br>cmd: <code>{$cmd}</code>",
|
|
|
|
|
- UI::h('pre', [], implode("\n", $out))
|
|
|
|
|
|
|
+ " (return code: {$uiLogFiles['ret']})",
|
|
|
|
|
+ "<br>cmd: <code>{$uiLogFiles['cmd']}</code>",
|
|
|
|
|
+ UI::h('pre', [], implode("\n", $uiLogFiles['out']))
|
|
|
]);
|
|
]);
|
|
|
- $logName = end($out);// /tmp/se-debug-2017-01-30-plabudda-192.168.61.206-4qqrd0-1485775975.log
|
|
|
|
|
- {
|
|
|
|
|
- if ("{$this->logPathPrefix}se-debug-" != substr($logName, 0, strlen("{$this->logPathPrefix}se-debug-"))) throw new Exception("Wrong log name prefix");
|
|
|
|
|
- if ('.log' != substr($logName, -1 * strlen('.log'))) throw new Exception("Wrong log name suffix");
|
|
|
|
|
- $logName = substr($logName, strlen("{$this->logPathPrefix}se-debug-"), -1 * strlen('.log'));
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
$this->printLogFileView('debug', $logName);
|
|
$this->printLogFileView('debug', $logName);
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|