Skip to content

Commit

Permalink
New options to exclude specific log files from log panels.
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbj committed Jul 10, 2024
1 parent 9627de6 commit 7d0c69c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
30 changes: 29 additions & 1 deletion TracyDebugger.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function getModuleInfo() {
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
'author' => 'Adrian Jones',
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
'version' => '4.26.31',
'version' => '4.26.32',
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
'singular' => true,
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
Expand Down Expand Up @@ -217,6 +217,8 @@ static public function getDefaultData() {
"outputMode" => 'detect',
"showLocation" => array('Tracy\Dumper::LOCATION_SOURCE', 'Tracy\Dumper::LOCATION_LINK', 'Tracy\Dumper::LOCATION_CLASS'),
"logSeverity" => array(),
"excludedPwLogFiles" => array('session', 'modules', 'file-compiler'),
"excludedTracyLogFiles" => array(),
"numLogEntries" => 10,
"collapse" => 14,
"collapse_count" => 7,
Expand Down Expand Up @@ -4289,6 +4291,32 @@ public function getModuleConfigInputfields(array $data) {
$fieldset->label = __('ProcessWire and Tracy Log panels', __FILE__);
$wrapper->add($fieldset);

$f = $this->wire('modules')->get("InputfieldAsmSelect");
$f->attr('name', 'excludedPwLogFiles');
$f->label = __('Excluded PW log files', __FILE__);
$f->description = __('Select log files to be excluded', __FILE__);
$f->notes = __('Useful if you have logs that are written to regularly on user interaction that are overwhelming more useful alert/error/warning logs.', __FILE__);
$f->columnWidth = 50;
$f->setAsmSelectOption('sortable', false);
foreach($this->wire('log')->getLogs() as $k => $v) {
$f->addOption($k);
}
if($data['excludedPwLogFiles']) $f->attr('value', $data['excludedPwLogFiles']);
$fieldset->add($f);

$f = $this->wire('modules')->get("InputfieldAsmSelect");
$f->attr('name', 'excludedTracyLogFiles');
$f->label = __('Excluded Tracy log files', __FILE__);
$f->description = __('Select log files to be excluded', __FILE__);
$f->notes = __('Useful if you have logs that are written to regularly on user interaction that are overwhelming more useful alert/error/warning logs.', __FILE__);
$f->columnWidth = 50;
$f->setAsmSelectOption('sortable', false);
foreach((new \TracyLogsPanel())->getLogs() as $k => $v) {
$f->addOption($k);
}
if($data['excludedTracyLogFiles']) $f->attr('value', $data['excludedTracyLogFiles']);
$fieldset->add($f);

$f = $this->wire('modules')->get("InputfieldInteger");
$f->attr('name', 'numLogEntries');
$f->label = __('Number of log entries', __FILE__);
Expand Down
4 changes: 4 additions & 0 deletions panels/ProcesswireLogsPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public function getTab() {

foreach($logs as $log) {

if(in_array($log['name'], \TracyDebugger::getDataValue("excludedPwLogFiles"))) {
continue;
}

if(isset($custom_logs) && array_key_exists($log['name'], $custom_logs_config['customLogsParsed'])) {
$isCustom = true;
$lines = $custom_logs->getEntries($log['name']);
Expand Down
4 changes: 4 additions & 0 deletions panels/TracyLogsPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function getTab() {
$errorLogs = array('error', 'exception', 'critical');
foreach($logs as $log) {

if(in_array($log['name'], \TracyDebugger::getDataValue("excludedTracyLogFiles"))) {
continue;
}

$lines = \TracyDebugger::tailCustom($this->wire('config')->paths->logs.'tracy/'.$log['name'].'.log', \TracyDebugger::getDataValue("numLogEntries"));
$lines = mb_convert_encoding($lines, 'UTF-8');
$lines = explode("\n", $lines);
Expand Down

0 comments on commit 7d0c69c

Please sign in to comment.