WatchdogAggregatorSensorPlugin.php in Monitoring 8
File
src/Plugin/monitoring/SensorPlugin/WatchdogAggregatorSensorPlugin.php
View source
<?php
namespace Drupal\monitoring\Plugin\monitoring\SensorPlugin;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\monitoring\SensorPlugin\ExtendedInfoSensorPluginInterface;
class WatchdogAggregatorSensorPlugin extends DatabaseAggregatorSensorPlugin implements ExtendedInfoSensorPluginInterface {
protected $configurableTable = FALSE;
protected $configurableTimestampField = FALSE;
public function verboseResultUnaggregated(array &$output) {
parent::verboseResultUnaggregated($output);
if (isset($output['verbose_sensor_result']['#rows']) && array_key_exists('message', $output['verbose_sensor_result']['#header']) && array_key_exists('variables', $output['verbose_sensor_result']['#header'])) {
unset($output['verbose_sensor_result']['#header']['variables']);
foreach ($output['verbose_sensor_result']['#rows'] as $delta => $row) {
$output['verbose_sensor_result']['#rows'][$delta]['wid'] = Link::fromTextAndUrl($row['wid'], Url::fromUserInput('/admin/reports/dblog/event/' . $row['wid']))
->toString();
$output['verbose_sensor_result']['#rows'][$delta]['message'] = new FormattableMarkup($row['message'], unserialize($row['variables']));
unset($output['verbose_sensor_result']['#rows'][$delta]['variables']);
}
}
}
public function verboseResultHistory(array &$output) {
parent::verboseResultHistory($output);
if (isset($output['verbose_sensor_history']['#description'])) {
$output['verbose_sensor_history']['#description'] = t('Records in dblog limited to :limit records. :parent_info', [
':limit' => \Drupal::configFactory()
->get('dblog.settings')
->get('row_limit'),
':parent_info' => $output['verbose_sensor_history']['#description'],
]);
}
}
public function getDefaultConfiguration() {
$default_config = array(
'settings' => array(
'table' => 'watchdog',
'time_interval_field' => 'timestamp',
),
);
return $default_config;
}
}