magento-lts
magento-lts copied to clipboard
Exception noise from OAuth and REST (API2 )
I have a project with OAuth REST which is interfacing with a mobile app. The exception.log is filling up with millions of lines due to unnecessary logs:
Mage_Api2_Exception: oauth_problem=token_rejected in .../app/code/core/Mage/Api2/Model/Auth/Adapter/Oauth.php:49 Mage_Api2_Exception: Missing required params in .../app/code/core/Mage/Api2/Model/Resource.php:629 Mage_Oauth_Exception in .../app/Mage.php:648, .../app/code/core/Mage/Oauth/Model/Server.php(421)
Each exception has 11 lines or more.
Preconditions (*)
Any version.
Steps to reproduce (*)
May be by unit tests?
Expected result (*)
- Do not
Mage::logException($e)forMage_Api2_ExceptionandMage_Oauth_Exception? - Only log one line per exception?
Actual result (*)
Noise in exception.log making it hard to detect the signal, problems that require attention.
Mage_Api2_Exception: Missing required params in .../app/code/core/Mage/Api2/Model/Resource.php:629
Please post that lines. Looks like modified code. (?)
Please post that lines. Looks like modified code. (?)
The project has lots of custom API2. When the client requests certain info but fail some validations, an exception is thrown, an example of bad request:
$this->_critical('Missing nationality', Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
That stops further execution and informs the client (mobile phone) its request is bad, but I do not want to log this, it's unnecessary. But currently, $this->_critical() logs it in exception.log.
https://github.com/OpenMage/magento-lts/blob/00de7b5f4db329d16bff33ca497f288ebe369cd2/app/code/core/Mage/Api2/Model/Resource.php#L613-L626
Line ~629~ 625 is throw new Mage_Api2_Exception($message, $code); in my project.
Line 629 is
throw new Mage_Api2_Exception($message, $code);in my project.
In core thats line 625 ...
Isnt it correct to log "$this->_critical('Missing nationality'"?
Sure, it is OK to log, but it's unnecessary to include the trace in the log.
The exceptions are log here: https://github.com/OpenMage/magento-lts/blob/cf16ac85e2f0767f4a544c280410ac1ac3034576/app/code/core/Mage/Api2/Model/Server.php#L104-L107
What's the best way to handle it?