Skip to content

Commit

Permalink
move priority constans to Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgu committed Aug 17, 2016
1 parent 7f788b1 commit 48fd2ba
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Using
```php
$logger = $this->getServiceLocator()->get(\T4web\Log\Logger::class);
$logger->log('general', 'test message');
$logger->log('general', 'test message', \T4web\Log\Domain\Log\Log::PRIORITY_ERR, ['file' => __FILE__, 'line' => __LINE__]);
$logger->log('general', 'test message', \T4web\Log\Logger::PRIORITY_ERR, ['file' => __FILE__, 'line' => __LINE__]);
```

If you use `t4web\admin` it will looks like this:
Expand Down
24 changes: 12 additions & 12 deletions config/sebaks-view.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
'label' => 'Priority',
'options' => [
'' => 'All',
Domain\Log\Log::PRIORITY_ERR => 'ERR',
Domain\Log\Log::PRIORITY_WARN => 'WARN',
Domain\Log\Log::PRIORITY_INFO => 'INFO',
Domain\Log\Log::PRIORITY_DEBUG => 'DEBUG',
Logger::PRIORITY_ERR => 'ERR',
Logger::PRIORITY_WARN => 'WARN',
Logger::PRIORITY_INFO => 'INFO',
Logger::PRIORITY_DEBUG => 'DEBUG',
],
],
'fromParent' => [
Expand Down Expand Up @@ -224,16 +224,16 @@
'data' => [
'static' => [
'textValueMap' => [
Domain\Log\Log::PRIORITY_ERR => 'ERR',
Domain\Log\Log::PRIORITY_WARN => 'WARN',
Domain\Log\Log::PRIORITY_INFO => 'INFO',
Domain\Log\Log::PRIORITY_DEBUG => 'DEBUG',
Logger::PRIORITY_ERR => 'ERR',
Logger::PRIORITY_WARN => 'WARN',
Logger::PRIORITY_INFO => 'INFO',
Logger::PRIORITY_DEBUG => 'DEBUG',
],
'colorValueMap' => [
Domain\Log\Log::PRIORITY_ERR => 'danger',
Domain\Log\Log::PRIORITY_WARN => 'warning',
Domain\Log\Log::PRIORITY_INFO => 'info',
Domain\Log\Log::PRIORITY_DEBUG => 'default',
Logger::PRIORITY_ERR => 'danger',
Logger::PRIORITY_WARN => 'warning',
Logger::PRIORITY_INFO => 'info',
Logger::PRIORITY_DEBUG => 'default',
],
],
'fromParent' => ['priority' => 'value'],
Expand Down
9 changes: 0 additions & 9 deletions src/Domain/Log/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@

class Log extends Entity
{
const PRIORITY_EMERG = 1;
const PRIORITY_ALERT = 2;
const PRIORITY_CRIT = 3;
const PRIORITY_ERR = 4;
const PRIORITY_WARN = 5;
const PRIORITY_NOTICE = 6;
const PRIORITY_INFO = 7;
const PRIORITY_DEBUG = 8;

/**
* @var string
*/
Expand Down
11 changes: 10 additions & 1 deletion src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

class Logger
{
const PRIORITY_EMERG = 1;
const PRIORITY_ALERT = 2;
const PRIORITY_CRIT = 3;
const PRIORITY_ERR = 4;
const PRIORITY_WARN = 5;
const PRIORITY_NOTICE = 6;
const PRIORITY_INFO = 7;
const PRIORITY_DEBUG = 8;

/**
* @var RepositoryInterface
*/
Expand Down Expand Up @@ -37,7 +46,7 @@ public function __construct(
* @param int $priority
* @param array $extras
*/
public function log($scope, $message, $priority = Log::PRIORITY_INFO, $extras = [])
public function log($scope, $message, $priority = self::PRIORITY_INFO, $extras = [])
{
$scopeId = array_search($scope, $this->scopes);

Expand Down

0 comments on commit 48fd2ba

Please sign in to comment.