Commit 1bf55951 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-721 Added option to tail the error log file, "wide view" can now also

be disabled.

Released under the Affero GNU General Public License (AGPL) version 3.
parent e757cdc6
...@@ -531,14 +531,16 @@ class ZPushTop { ...@@ -531,14 +531,16 @@ class ZPushTop {
$this->status = "resetted"; $this->status = "resetted";
$this->statusexpire = $this->currenttime+2; $this->statusexpire = $this->currenttime+2;
} }
// enable/disable wide view
else if ($cmds[0] == "wide" || $cmds[0] == "w") { else if ($cmds[0] == "wide" || $cmds[0] == "w") {
$this->wide = true; $this->wide = ! $this->wide;
$this->status = "w i d e view"; $this->status = ($this->wide)?"w i d e view" : "normal view";
$this->statusexpire = $this->currenttime+2; $this->statusexpire = $this->currenttime+2;
} }
else if ($cmds[0] == "help" || $cmds[0] == "h") { else if ($cmds[0] == "help" || $cmds[0] == "h") {
$this->helpexpire = $this->currenttime+20; $this->helpexpire = $this->currenttime+20;
} }
// grep the log file
else if (($cmds[0] == "log" || $cmds[0] == "l") && isset($cmds[1]) ) { else if (($cmds[0] == "log" || $cmds[0] == "l") && isset($cmds[1]) ) {
if (!file_exists(LOGFILE)) { if (!file_exists(LOGFILE)) {
$this->status = "Logfile can not be found: ". LOGFILE; $this->status = "Logfile can not be found: ". LOGFILE;
...@@ -549,6 +551,7 @@ class ZPushTop { ...@@ -549,6 +551,7 @@ class ZPushTop {
} }
$this->statusexpire = time()+5; // it might be much "later" now $this->statusexpire = time()+5; // it might be much "later" now
} }
// tail the log file
else if (($cmds[0] == "tail" || $cmds[0] == "t")) { else if (($cmds[0] == "tail" || $cmds[0] == "t")) {
if (!file_exists(LOGFILE)) { if (!file_exists(LOGFILE)) {
$this->status = "Logfile can not be found: ". LOGFILE; $this->status = "Logfile can not be found: ". LOGFILE;
...@@ -565,6 +568,23 @@ class ZPushTop { ...@@ -565,6 +568,23 @@ class ZPushTop {
} }
$this->statusexpire = time()+5; // it might be much "later" now $this->statusexpire = time()+5; // it might be much "later" now
} }
// tail the error log file
else if (($cmds[0] == "error" || $cmds[0] == "e")) {
if (!file_exists(LOGERRORFILE)) {
$this->status = "Error logfile can not be found: ". LOGERRORFILE;
}
else {
$this->doingTail = true;
$this->scrClear();
$this->scrPrintAt(1,0,$this->scrAsBold("Press CTRL+C to return to Z-Push-Top\n\n"));
$secondary = "";
if (isset($cmds[1])) $secondary = " -n 200 | grep ".escapeshellarg($cmds[1]);
system('bash -c "tail -f '. LOGERRORFILE . $secondary . '" > `tty`');
$this->doingTail = false;
$this->status = "Returning from tail, updating data";
}
$this->statusexpire = time()+5; // it might be much "later" now
}
else if ($cmds[0] != "") { else if ($cmds[0] != "") {
$this->status = sprintf("Command '%s' unknown", $cmds[0]); $this->status = sprintf("Command '%s' unknown", $cmds[0]);
...@@ -630,6 +650,7 @@ class ZPushTop { ...@@ -630,6 +650,7 @@ class ZPushTop {
$h[] = " ".$this->scrAsBold("f:")." or ".$this->scrAsBold("filter:")."\t\tWithout a search word: resets the filter."; $h[] = " ".$this->scrAsBold("f:")." or ".$this->scrAsBold("filter:")."\t\tWithout a search word: resets the filter.";
$h[] = " ".$this->scrAsBold("l:STR")." or ".$this->scrAsBold("log:STR")."\tIssues 'less +G' on the logfile, after grepping on the optional STR."; $h[] = " ".$this->scrAsBold("l:STR")." or ".$this->scrAsBold("log:STR")."\tIssues 'less +G' on the logfile, after grepping on the optional STR.";
$h[] = " ".$this->scrAsBold("t:STR")." or ".$this->scrAsBold("tail:STR")."\tIssues 'tail -f' on the logfile, grepping for optional STR."; $h[] = " ".$this->scrAsBold("t:STR")." or ".$this->scrAsBold("tail:STR")."\tIssues 'tail -f' on the logfile, grepping for optional STR.";
$h[] = " ".$this->scrAsBold("e:STR")." or ".$this->scrAsBold("error:STR")."\tIssues 'tail -f' on the error logfile, grepping for optional STR.";
$h[] = " ".$this->scrAsBold("r")." or ".$this->scrAsBold("reset")."\t\tResets 'wide' or 'filter'."; $h[] = " ".$this->scrAsBold("r")." or ".$this->scrAsBold("reset")."\t\tResets 'wide' or 'filter'.";
$h[] = " ".$this->scrAsBold("o:")." or ".$this->scrAsBold("option:")."\t\tSets display options. Valid options specified below"; $h[] = " ".$this->scrAsBold("o:")." or ".$this->scrAsBold("option:")."\t\tSets display options. Valid options specified below";
$h[] = " ".$this->scrAsBold(" p")." or ".$this->scrAsBold("push")."\t\tLists/not lists active and open push connections."; $h[] = " ".$this->scrAsBold(" p")." or ".$this->scrAsBold("push")."\t\tLists/not lists active and open push connections.";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment