Skip to content

Commit

Permalink
common: disable logging for level=NONE
Browse files Browse the repository at this point in the history
Previously, we did not add any logging handlers when logger_level
was set to NONE. This made Monolog to default to a stderr handler.
Let’s use NullHandler to correctly disable logging.
  • Loading branch information
jtojnar committed Jan 21, 2019
1 parent c83fbdf commit 2395a12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Bug fixes
- Reddit spout allows wider range of URLs, including absolute URLs and searches ([#1033](https://github.com/SSilence/selfoss/pull/1033))
- Improved compatibility with PHP 7.2 ([#1049](https://github.com/SSilence/selfoss/issues/1049))
- `logger_level=NONE` is now handled correctly ([#1077](https://github.com/SSilence/selfoss/issues/1077))

### API changes
- `tags` attribute is now consistently array of strings, numbers are numbers and booleans are booleans. **This might break third-party clients that have not updated yet.** ([#948](https://github.com/SSilence/selfoss/pull/948))
Expand Down
5 changes: 4 additions & 1 deletion common.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Monolog\Formatter\LineFormatter;
use Monolog\Handler\ErrorLogHandler;
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;

Expand Down Expand Up @@ -39,7 +40,9 @@

// init logger
$log = new Logger('selfoss');
if ($f3->get('logger_level') !== 'NONE') {
if ($f3->get('logger_level') === 'NONE') {
$log->pushHandler(new NullHandler);
} else {
$logger_destination = $f3->get('logger_destination');

if (strpos($logger_destination, 'file:') === 0) {
Expand Down

0 comments on commit 2395a12

Please sign in to comment.