You're looking through the apache error log and you see this:
[Fri Oct 15 17:58:43.458518 2021] [php7:error] [pid 41144] [client ::1:46744] PHP Fatal error: Uncaught Error: Call to a member function getStockStatus() on bool in /var/www/example.com.localhost/vendor/magento/module-catalog-inventory/Model/Quote/Item/QuantityValidator.php:157\nStack trace:\n#0 /var/www/example.com.localhost/vendor/magento/module-catalog-inventory/Observer/QuantityValidatorObserver.php(34): Magento\\CatalogInventory\\Model\\Quote\\Item\\QuantityValidator->validate(Object(Magento\\Framework\\Event\\Observer))\n#1 /var/www/example.com.localhost/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\\CatalogInventory\\Observer\\QuantityValidatorObserver->execute(Object(Magento\\Framework\\Event\\Observer))\n#2 /var/www/example.com.localhost/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\\Framework\\Event\\Invoker\\InvokerDefault->_callObserverMethod(Object(Magento\\CatalogInventory\\Observer\\QuantityValidatorObserver), Object(Magento\\Framework\\Event\\Observer))\n#3 /var/www/example.com.localhost/vendor/magento/module-staging/Model/Event/Manager.php(97): Magento\\Framework\\Event\\Invoke in /var/www/example.com.localhost/vendor/magento/module-catalog-inventory/Model/Quote/Item/QuantityValidator.php on line 157, referer: http://example.com.localhost/run-away-basics-rugzak-15039001.html
[Fri Oct 15 18:12:15.634605 2021] [php7:error] [pid 41145] [client ::1:53320] PHP Fatal error: Uncaught Error: Call to a member function getStockStatus() on bool in /var/www/example.com.localhost/vendor/magento/module-catalog-inventory/Model/Quote/Item/QuantityValidator.php:157\nStack trace:\n#0 /var/www/example.com.localhost/vendor/magento/module-catalog-inventory/Observer/QuantityValidatorObserver.php(34): Magento\\CatalogInventory\\Model\\Quote\\Item\\QuantityValidator->validate(Object(Magento\\Framework\\Event\\Observer))\n#1 /var/www/example.com.localhost/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\\CatalogInventory\\Observer\\QuantityValidatorObserver->execute(Object(Magento\\Framework\\Event\\Observer))\n#2 /var/www/example.com.localhost/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\\Framework\\Event\\Invoker\\InvokerDefault->_callObserverMethod(Object(Magento\\CatalogInventory\\Observer\\QuantityValidatorObserver), Object(Magento\\Framework\\Event\\Observer))\n#3 /var/www/example.com.localhost/vendor/magento/module-staging/Model/Event/Manager.php(97): Magento\\Framework\\Event\\Invoke in /var/www/example.com.localhost/vendor/magento/module-catalog-inventory/Model/Quote/Item/QuantityValidator.php on line 157, referer: http://example.com.localhost/run-away-basics-rugzak-15039001.html
Which isn't really handy for debugging
Now if you use the below command in bash, to pretty format the apache 2 error log for php fatal errors, you get a nicer output(in my opinion)
tail -f /var/log/apache2/error.log | grep 'PHP Fatal error' | grep '/var/www/example.com' | sed -u -e 's/\\n/\n/g' | sed -e 's/\.php(\([0-9]*\)):\s/.php:\1 /g'
[Fri Oct 15 17:41:40.026908 2021] [php7:error] [pid 37596] [client ::1:37662] PHP Fatal error: Uncaught Error: Cannot instantiate interface Magento\\Framework\\App\\Area\\FrontNameResolverInterface in /var/www/example.com.localhost/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:50
Stack trace:
#0 /var/www/example.com.localhost/vendor/magento/framework/ObjectManager/ObjectManager.php:70 Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->create('Magento\\\\Framewo...')
#1 /var/www/example.com.localhost/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:167 Magento\\Framework\\ObjectManager\\ObjectManager->get('Magento\\\\Framewo...')
#2 /var/www/example.com.localhost/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:273 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->resolveArgument(Array, 'Magento\\\\Framewo...', NULL, 'front_name_reso...', 'BigBridge\\\\Stock...')
#3 /var/www/example.com.localhost/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:236 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->getResolvedArgument('BigB in /var/www/example.com.localhost/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php on line 50, referer: http://example.com.localhost/run-away-basics-rugzak-15039001.html
[Fri Oct 15 17:52:10.110658 2021] [php7:error] [pid 39564] [client ::1:43134] PHP Fatal error: Uncaught Error: Call to a member function getStockStatus() on bool in /var/www/example.com.localhost/vendor/magento/module-catalog-inventory/Model/Quote/Item/QuantityValidator.php:157
Stack trace:
#0 /var/www/example.com.localhost/vendor/magento/module-catalog-inventory/Observer/QuantityValidatorObserver.php:34 Magento\\CatalogInventory\\Model\\Quote\\Item\\QuantityValidator->validate(Object(Magento\\Framework\\Event\\Observer))
#1 /var/www/example.com.localhost/vendor/magento/framework/Event/Invoker/InvokerDefault.php:88 Magento\\CatalogInventory\\Observer\\QuantityValidatorObserver->execute(Object(Magento\\Framework\\Event\\Observer))
#2 /var/www/example.com.localhost/vendor/magento/framework/Event/Invoker/InvokerDefault.php:74 Magento\\Framework\\Event\\Invoker\\InvokerDefault->_callObserverMethod(Object(Magento\\CatalogInventory\\Observer\\QuantityValidatorObserver), Object(Magento\\Framework\\Event\\Observer))
#3 /var/www/example.com.localhost/vendor/magento/module-staging/Model/Event/Manager.php:97 Magento\\Framework\\Event\\Invoke in /var/www/example.com.localhost/vendor/magento/module-catalog-inventory/Model/Quote/Item/QuantityValidator.php on line 157, referer: http://example.com.localhost/run-away-basics-rugzak-15039001.html
Now if you're using phpstorm and you install the plugin Awesome console they'll even become clickable in run output and console output, so you can simply click, go to the correct file and line and debug from there.
Say we add a composer script for easy composer run configuration in php storm, even then the output there is clickable to open the file at line.
"scripts": {
"dev-server-log": [
"tail -f /var/log/apache2/error.log | grep '/var/www/example.com' | sed -u -e 's/\\\\n/\\n/g' | sed -e 's/\\.php(\\([0-9]*\\)):\\s/.php:\\1 /g' "
]
},
The awesome console plugin isn't perfect, and doesn't always make all links clickable, but every time you don't need to select a line and open the file that way, is time saved.
Happy coding!
Top comments (0)