Skip to content

Commit

Permalink
Merge pull request #185 from schmunk42/feature/log-config
Browse files Browse the repository at this point in the history
Feature/log config
  • Loading branch information
cornernote committed Jan 16, 2017
2 parents 5f34b95 + 08b12dc commit dd7273c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/Audit.php
Expand Up @@ -117,6 +117,12 @@ class Audit extends Module
*/
public $batchSave = true;

/**
* @var array Default log levels to filter and process
*/
public $logConfig = ['levels' => ['error', 'warning', 'info', 'profile']];


/**
* @var array|Panel[] list of panels that should be active/tracking/available during the auditing phase.
* If the value is a simple string, it is the identifier of an internal panel to activate (with default settings)
Expand Down Expand Up @@ -208,7 +214,11 @@ public function init()
$app->on(Application::EVENT_AFTER_REQUEST, [$this, 'onAfterRequest']);

// Activate the logging target
$this->logTarget = $app->getLog()->targets['audit'] = new LogTarget($this);
if (empty($app->getLog()->targets['audit'])) {
$this->logTarget = $app->getLog()->targets['audit'] = new LogTarget($this, $this->logConfig);
} else {
$this->logTarget = $app->getLog()->targets['audit'];
}

// Boot all active panels
$this->normalizePanelConfiguration();
Expand Down
2 changes: 1 addition & 1 deletion src/LogTarget.php
Expand Up @@ -69,7 +69,7 @@ public function export()
*/
public function collect($messages, $final)
{
$this->messages = array_merge($this->messages, $messages);
$this->messages = array_merge($this->messages, static::filterMessages($messages, $this->getLevels(), $this->categories, $this->except));
if ($final) {
$this->export();
}
Expand Down

0 comments on commit dd7273c

Please sign in to comment.