Skip to content

[FrameworkBundle] framework.php_errors.log now accept a log level #26504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Simperfit
Copy link
Contributor

@Simperfit Simperfit commented Mar 13, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #26267
License MIT
Doc PR todo

We are testing that framework.php_errors.log is either a bool or an int (set the value of the log level you want).
This fixes #26267, so it gives a way to not log some level on production.

@nicolas-grekas
Copy link
Member

would be great to turn the framework.php_errors.log config entry into a "bool|int", and when an "int" is provided, use the value to set the parameter

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Mar 13, 2018
@Simperfit Simperfit force-pushed the feature/add-a-parameter-for-log-level branch from d71b26f to 5b6a4fe Compare March 14, 2018 11:34
@Simperfit
Copy link
Contributor Author

@nicolas-grekas I have changed this PR, could you please guide me on how to write test for this ?

@Simperfit Simperfit changed the title [FrameworkBundle] add a parameter for the debug production log level [FrameworkBundle] framework.php_errors.log now accept a log level Mar 14, 2018
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for tests, please check the existing ones, I don't have specific ideas on the topic sorry

@@ -601,10 +601,14 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con

$definition = $container->findDefinition('debug.debug_handlers_listener');

if (!$config['log']) {
if (\is_bool($config['log']) && !$config['log']) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!$config['log']) { is enough: 0 also disables the logger

$definition->replaceArgument(1, null);
}

if (\is_int($config['log'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (\is_int($config['log']) && $config['log']) {

@@ -833,7 +833,7 @@ private function addPhpErrorsSection(ArrayNodeDefinition $rootNode)
->info('PHP errors handling configuration')
->addDefaultsIfNotSet()
->children()
->booleanNode('log')
->scalarNode('log')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe forbid anything else than a bool|int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Simperfit Simperfit force-pushed the feature/add-a-parameter-for-log-level branch from 5b6a4fe to b02c7d7 Compare March 26, 2018 06:33
@Simperfit
Copy link
Contributor Author

Status: Needs Review

@Simperfit Simperfit force-pushed the feature/add-a-parameter-for-log-level branch from b02c7d7 to c713dca Compare March 26, 2018 15:08
@Simperfit
Copy link
Contributor Author

Tests Fixed.

->info('Use the app logger instead of the PHP logger for logging PHP errors.')
->defaultValue($this->debug)
->treatNullLike($this->debug)
->validate()
->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v)); })
->thenInvalid('The "php_errors.log" parameter should be either a int or a boolean.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either an integer or a boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot updated.

@Simperfit Simperfit force-pushed the feature/add-a-parameter-for-log-level branch from c713dca to 556c6c1 Compare March 27, 2018 07:45
->info('Use the app logger instead of the PHP logger for logging PHP errors.')
->defaultValue($this->debug)
->treatNullLike($this->debug)
->validate()
->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v)); })
->thenInvalid('The "php_errors.log" parameter should be either a integer or a boolean.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an integer :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good now :p.

@Simperfit Simperfit force-pushed the feature/add-a-parameter-for-log-level branch from 556c6c1 to 664f821 Compare March 27, 2018 14:39
@fabpot
Copy link
Member

fabpot commented Mar 27, 2018

Thank you @Simperfit.

@fabpot fabpot merged commit 664f821 into symfony:master Mar 27, 2018
fabpot added a commit that referenced this pull request Mar 27, 2018
…a log level (Simperfit)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[FrameworkBundle] framework.php_errors.log now accept a log level

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #26267   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        |  todo <!-- required for new features -->

We are testing that `framework.php_errors.log` is either a bool or an int (set the value of the log level you want).
This fixes #26267, so it gives a way to not log some level on production.

Commits
-------

664f821 [FrameworkBundle] framework.php_errors.log now accept a log level
@Simperfit Simperfit deleted the feature/add-a-parameter-for-log-level branch March 30, 2018 09:22
nicolas-grekas added a commit that referenced this pull request Apr 9, 2018
…yrixx)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[FrameworkBundle] Fixed configuration of php_errors.log

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26504 and #26740 (wrong implementation)
| License       | MIT
| Doc PR        |

Commits
-------

8e0fcf9 [FrameworkBundle] Fixed configuration of php_errors.log
@fabpot fabpot mentioned this pull request May 7, 2018
@@ -833,10 +833,14 @@ private function addPhpErrorsSection(ArrayNodeDefinition $rootNode)
->info('PHP errors handling configuration')
->addDefaultsIfNotSet()
->children()
->booleanNode('log')
->scalarNode('log')
->info('Use the app logger instead of the PHP logger for logging PHP errors.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really descriptive now?

@mathieu-pousse
Copy link

Hi,

This PR looks great to me, but I am not sure to ensure the aim.
Does the log level behind the scene correspond to something like 'E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED & ~E_STRICT' or to DEVUG, INFO, WARN, ?

In any case, I think this should be explain in the documentation

@SublimeRaiser
Copy link

This PR looks great to me, but I am not sure to ensure the aim.
Does the log level behind the scene correspond to something like 'E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED & ~E_STRICT' or to DEVUG, INFO, WARN, ?

In any case, I think this should be explain in the documentation

Here is a link to the docs: https://symfony.com/doc/current/reference/configuration/framework.html#log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecated error are logged on production
7 participants