Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/82'
Browse files Browse the repository at this point in the history
Close #82
  • Loading branch information
weierophinney committed Apr 9, 2018
2 parents 54184c5 + c08a0a7 commit 7425665
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
47 changes: 42 additions & 5 deletions doc/book/service-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,35 @@ return [
'log' => [
'MyLogger' => [
'writers' => [
[
'stream' => [
'name' => 'stream',
'priority' => Logger::DEBUG,
'priority' => \Zend\Log\Logger::ALERT,
'options' => [
'stream' => 'php://output',
'formatter' => [
'name' => 'MyFormatter',
'name' => \Zend\Log\Formatter\Simple::class,
'options' => [
'format' => '%timestamp% %priorityName% (%priority%): %message% %extra%',
'dateTimeFormat' => 'c',
],
],
'filters' => [
[
'name' => 'MyFilter',
'priority' => [
'name' => 'priority',
'options' => [
'operator' => '<=',
'priority' => \Zend\Log\Logger::INFO,
],
],
],
],
],
],
'processors' => [
'requestid' => [
'name' => \Zend\Log\Processor\RequestId::class,
],
],
],
],
];
Expand All @@ -73,6 +86,30 @@ the configuration (`MyLogger`):
$logger = $container->get('MyLogger');
```

For the formatter and the filters, only the `name` is required, the options have
default values (the values set in this example are the default ones). When only
the name is needed, a shorter format can be used:

```php
// module.config.php
'options' => [
'stream' => 'php://output',
'formatter' => \Zend\Log\Formatter\Simple::class,
'filters' => [
'priority' => \Zend\Log\Filter\Priority::class,
],
],
];
```

Because the main filter is `Priority`, it can be set directly too:

```php
// module.config.php
'filters' => \Zend\Log\Logger::INFO,
];
```

## Custom Writers, Formatters, Filters, and Processors

In the `LoggerAbstractServiceFactory` example above, a custom formatter (called
Expand Down
14 changes: 14 additions & 0 deletions doc/book/writers.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,17 @@ which means that:
- higher integer values indicate higher priority (triggered earliest);
- lower integer values (including negative values) have lower priority
(triggered last).

## Distinction between priority in the queue of writers and the filter `Priority`

When you add a writer to the logger, you can set its priority as a second
argument. This priority is the priority in the queue of all writers of the
logger. It can be any integer, and the default is `1` (`\Zend\Log\Logger::ALERT`)
for the writers; the bigger the number, the higher the priority. A writer with a
lower priority will be triggered later, so `ALERT` is triggered after `DEBUG`.
For details on the list of the priorities, see the section entitled [Using Built-in Priorities](intro.md#using-built-in-priorities).

This priority should not be confused with the [`Priority` filter](filters.md#available-filters),
which determines if a message meets a _severity_ threshold. When a `Priority`
filter is attached, the writer will output the message only when the filter is
lower or equal (by default) to the priority (the biggest severity is 0).

0 comments on commit 7425665

Please sign in to comment.