Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tests/var
vendor
.php-cs-fixer.cache
composer.phar
Expand Down
16 changes: 16 additions & 0 deletions tests/DependencyInjection/Fixtures/php/handlers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return static function (Symfony\Config\MonologConfig $monologConfig): void {
$monologConfig
->handler('noop')
->type('noop');
};
73 changes: 73 additions & 0 deletions tests/DependencyInjection/Fixtures/php/handlers_with_channels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();

$services->set('security_logger', 'Foo')
->tag('monolog.logger', ['channel' => 'security']);

$services->set('doctrine_logger', 'Foo')
->tag('monolog.logger', ['channel' => 'doctrine']);

$services->set('foo_logger', 'Foo')
->tag('monolog.logger', ['channel' => 'foo']);

$services->set('bar_logger', 'Foo')
->tag('monolog.logger', ['channel' => 'bar']);

$containerConfigurator->extension('monolog', [
'handlers' => [
'custom' => [
'type' => 'stream',
'path' => '/tmp/symfony.log',
'bubble' => false,
'level' => 'ERROR',
'channels' => 'foo',
],
'main' => [
'type' => 'group',
'members' => [
'nested',
],
'channels' => [
'!foo',
'!bar',
],
],
'nested' => [
'type' => 'stream',
],
'extra' => [
'type' => 'syslog',
'ident' => 'monolog',
'facility' => 'user',
'level' => 'ALERT',
],
'more' => [
'type' => 'native_mailer',
'to_email' => 'monitoring@example.org',
'from_email' => 'webmaster@example.org',
'subject' => 'Monolog report',
'level' => 'CRITICAL',
'channels' => [
'type' => 'inclusive',
'elements' => [
'security',
'doctrine',
],
],
],
],
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return static function (Symfony\Config\MonologConfig $monologConfig): void {
$monologConfig
->handler('swift')
->type('swift_mailer')
->fromEmail('error@example.com')
->toEmail(['dev1@example.com', 'dev2@example.com'])
->subject('An Error Occurred!')
->level('debug');
};
41 changes: 41 additions & 0 deletions tests/DependencyInjection/Fixtures/php/multiple_handlers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return static function (Symfony\Config\MonologConfig $monologConfig): void {
$monologConfig
->handler('custom')
->type('stream')
->path('/tmp/symfony.log')
->bubble(false)
->level('ERROR')
->filePermission(438);

$monologConfig
->handler('main')
->type('fingers_crossed')
->actionLevel('ERROR')
->passthruLevel('NOTICE')
->handler('nested');

$monologConfig
->handler('nested')
->type('stream');

$monologConfig
->handler('filtered')
->type('filter')
->acceptedLevels(['WARNING', 'ERROR'])
->handler('nested2');

$monologConfig
->handler('nested2')
->type('stream');
};
20 changes: 20 additions & 0 deletions tests/DependencyInjection/Fixtures/php/native_mailer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return static function (Symfony\Config\MonologConfig $monologConfig): void {
$monologConfig
->handler('mailer')
->type('native_mailer')
->fromEmail('foo@example.com')
->toEmail('bar@exemple.com')
->subject('a subject')
->headers(['Foo: bar', 'Baz: inga']);
};
41 changes: 41 additions & 0 deletions tests/DependencyInjection/Fixtures/php/new_and_priority.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__.'/new_and_priority_import.php');

$containerConfigurator->extension('monolog', [
'handlers' => [
'custom' => [
'type' => 'stream',
'path' => '/tmp/symfony.log',
'bubble' => true,
'level' => 'WARNING',
],
'first' => [
'type' => 'rotating_file',
'path' => '/tmp/monolog.log',
'bubble' => true,
'level' => 'ERROR',
'priority' => 3,
],
'last' => [
'type' => 'stream',
'path' => '/tmp/last.log',
'bubble' => true,
'level' => 'ERROR',
'priority' => -3,
],
],
]);
};
29 changes: 29 additions & 0 deletions tests/DependencyInjection/Fixtures/php/new_and_priority_import.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return static function (Symfony\Config\MonologConfig $monologConfig): void {
$monologConfig
->handler('custom')
->type('stream')
->path('/tmp/symfony.log')
->bubble(true)
->level('ERROR');

$monologConfig
->handler('main')
->type('buffer')
->level('INFO')
->handler('nested');

$monologConfig
->handler('nested')
->type('stream');
};
33 changes: 33 additions & 0 deletions tests/DependencyInjection/Fixtures/php/new_at_end.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__.'/new_at_end_import.php');

$containerConfigurator->extension('monolog', [
'handlers' => [
'custom' => [
'type' => 'stream',
'path' => '/tmp/symfony.log',
'bubble' => false,
'level' => 'WARNING',
],
'new' => [
'type' => 'stream',
'path' => '/tmp/monolog.log',
'bubble' => true,
'level' => 'ERROR',
],
],
]);
};
29 changes: 29 additions & 0 deletions tests/DependencyInjection/Fixtures/php/new_at_end_import.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return static function (Symfony\Config\MonologConfig $monologConfig): void {
$monologConfig
->handler('custom')
->type('stream')
->path('/tmp/symfony.log')
->bubble(true)
->level('ERROR');

$monologConfig
->handler('main')
->type('fingers_crossed')
->actionLevel('ERROR')
->handler('nested');

$monologConfig
->handler('nested')
->type('stream');
};
27 changes: 27 additions & 0 deletions tests/DependencyInjection/Fixtures/php/overwriting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__.'/overwriting_import.php');

$containerConfigurator->extension('monolog', [
'handlers' => [
'custom' => [
'type' => 'stream',
'path' => '/tmp/symfony.log',
'bubble' => true,
'level' => 'WARNING',
],
],
]);
};
29 changes: 29 additions & 0 deletions tests/DependencyInjection/Fixtures/php/overwriting_import.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return static function (Symfony\Config\MonologConfig $monologConfig): void {
$monologConfig
->handler('custom')
->type('stream')
->path('/tmp/symfony.log')
->bubble(false)
->level('ERROR');

$monologConfig
->handler('main')
->type('fingers_crossed')
->actionLevel('ERROR')
->handler('nested');

$monologConfig
->handler('nested')
->type('stream');
};
Loading
Loading