WPCS and Logging Errors
-
I’ve been using the WordPress Coding Standards sniffer to help me maintain good code and do things the WordPress way. I’m currently developing some code where I want to log certain errors that occur so I can tell when they happen and not just rely on user complaints to come in.
But I have been unable to figure out how to log errors in production in a way that is compliant with WPCS. It flags both error_log() and trigger_error() as needing to be behind a WP_DEBUG check. But that doesn’t help me when my code is in production and I’m not the one who may come across an error.
What’s the proper way to log errors in production in a WordPress environment? I feel like I’m missing something simple.
In case it helps, the use case I’m looking at now is logging an error if an issue occurs with an external API call. I’d still display a graceful message to the user, but I’d like to know if there are unexpected problems with the API calls.
- The topic ‘WPCS and Logging Errors’ is closed to new replies.