You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #21396 [DI] Enhance logging in compiler passes (nicolas-grekas)
This PR was merged into the 3.3-dev branch.
Discussion
----------
[DI] Enhance logging in compiler passes
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
We should log more in compiler passes - and this should be better integrated in usual log reports.
For logging more, let's drop LoggingFormatter and add a simple "log" method on ContainerBuilder.
For better integration, let's throw silenced notices - they can be caught by our Debug handler.
Commits
-------
fb200a0d2f [DI] Enhance logging in compiler passes
$this->container->log($this, sprintf('Autowiring\'s patterns "%s" for service "%s" don\'t match any method.', implode('", "', $notFound), $this->currentId));
@@ -57,9 +56,17 @@ public function getServiceReferenceGraph()
57
56
* Returns the logging formatter which can be used by compilation passes.
58
57
*
59
58
* @return LoggingFormatter
59
+
*
60
+
* @deprecated since version 3.3, to be removed in 4.0. Use the ContainerBuilder::log() method instead.
60
61
*/
61
62
publicfunctiongetLoggingFormatter()
62
63
{
64
+
if (null === $this->loggingFormatter) {
65
+
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the ContainerBuilder::log() method instead.', __METHOD__), E_USER_DEPRECATED);
66
+
67
+
$this->loggingFormatter = newLoggingFormatter();
68
+
}
69
+
63
70
return$this->loggingFormatter;
64
71
}
65
72
@@ -92,12 +99,24 @@ public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BE
92
99
* Adds a log message.
93
100
*
94
101
* @param string $string The log message
102
+
*
103
+
* @deprecated since version 3.3, to be removed in 4.0. Use the ContainerBuilder::log() method instead.
95
104
*/
96
105
publicfunctionaddLogMessage($string)
97
106
{
107
+
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the ContainerBuilder::log() method instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error('The '.__NAMESPACE__.'\LoggingFormatter class is deprecated since version 3.3 and will be removed in 4.0. Use the ContainerBuilder::log() method instead.', E_USER_DEPRECATED);
15
+
14
16
/**
15
17
* Used to format logging messages during the compilation.
$this->container->log($this, sprintf('Changed reference of service "%s" previously pointing to "%s" to "%s".', $this->currentId, $referenceId, $newId));
0 commit comments