deprecations
deprecations copied to clipboard
Incorrect filename is being logged
Bug Report
| Q | A |
|---|---|
| Version | 1.1.3 |
Summary
I've configured the deprecation logging against a PHP 8.1 project and am noticing that all my deprecation logs pointing to DBAL and deprecations packages, instead of the actual files where it's being triggered. This makes is very difficult for us to pinpoint the error in our project.
Current behavior
We've set up our logging in our app bootstrap as follows:
self::$deprecationLog = new Logger('DoctrineDeprecations');
if (Config::get('DEPRECATION_LOG_FILE')) {
$output = "[%datetime%] %level_name%: %message% %context% %extra%\n";
$formatter = new QuantumLineFormatter($output);
$stream = new StreamHandler(Config::get('DEPRECATION_LOG_FILE'), Config::get('LOG_LEVEL'));
$stream->setFormatter($formatter);
self::$deprecationLog->pushHandler($stream);
Deprecation::enableWithPsrLogger(self::$deprecationLog);
}
However, when we start our application and hit an area with known deprecations, the filename that is being logged is within the doctrine packages, instead of our code.
[2024-10-24T15:19:06.851853-04:00] NOTICE : Connection::fetchAssoc() is deprecated, use Connection::fetchAssociative() API instead. {"file":"/var/www/quantum/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":613,"package":"doctrine/dbal","link":"https://github.com/doctrine/dbal/pull/4019"} []
[2024-10-24T15:19:07.961852-04:00] NOTICE : Statement::execute() is deprecated, use Statement::executeQuery() or Statement::executeStatement() instead {"file":"/var/www/quantum/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php","line":166,"package":"doctrine/dbal","link":"https://github.com/doctrine/dbal/pull/4580"} []
I loaded up my debugger, and I did find the following within the Deprecation.php file:
Expected behavior
When a deprecation is logged, the filename should not be one related to doctrine projects. In this case, specifying $backtrace[1] appeared to be sufficient.