Intro and Warning

From time to time, you may run into some issues with tinyShield. If you do, first please contact support first. However, this tutorial will allow you to see how to debug tinyShield or at least see what’s going on via logs. Please keep in mind this does require editing of some core WordPress files, so if you’re not comfortable editing files please hire a professional or contact us.

Enable Logs

By default, tinyShield has built-in logging that will allow us to see what’s going on with tinyShield. This is not enabled by default but does adhere to the WP_DEBUG directive. Meaning that if WP_DEBUG is turned off, tinyShield debugging is turned off. So, it’s easy to enable logging yea? Yep, you guessed it. Enable WP_DEBUG and tinyShield will start logging what it’s doing. See https://codex.wordpress.org/WP_DEBUG for more information on WP_DEBUG

Smart Logging

Now, you could just enable WP_DEBUG and have all your errors show up for the world to see BUT that’s really never a good idea. So, let’s do this with a little intelligence. In your wp-config.php file, you should already have the following.

define(‘WP_DEBUG’, false);

So what we’re going to do is change this to ONLY show errors if it’s coming from our IP address. I’ve used this little trick for some time when debugging WordPress sites around the world.

if($_SERVER[‘REMOTE_ADDR’] == ‘XX.XX.XX.XX’){
define(‘WP_DEBUG’, true);
}else{
define(‘WP_DEBUG’, false);
}

Now what this little bit of code does, it says that if the IP address that we’re coming from matches XX.XX.XX.XX then we’re going to enable debugging but for everyone else turn debugging off. That way, only YOU will see what WP_DEBUG generates. Now, let’s take this one step further so that we don’t actually have anything displayed on the website and push all of this to a log file. Oh and if you don’t know your IP address, that is to replace XX.XX.XX.XX with an actual IP address visit this page and copy what’s there in place of the XX.XX.XX.XX. https://icanhazip.com

if($_SERVER[‘REMOTE_ADDR’] == ‘XX.XX.XX.XX’){
define(‘WP_DEBUG’, true);

define(‘WP_DEBUG_LOG’, true);
define(‘WP_DEBUG_DISPLAY’, false);
}else{
define(‘WP_DEBUG’, false);
}

Now, what this code does is the exact as the above code however it redirects all debugging information to a log file called debug.log which can be found under your wp-content folder or wherever your content folder is. When we look at that file it might look at little something like this.

[18-Apr-2021 01:32:26 UTC] tinyShield: {“subscription”:”community”,”action”:”allow”,”ip_address”:”XX.XX.XX.XX”,”rdns”:”XX.XX.XX.XX”,”geo_ip”:””,”is_tor_exit_node”:””}

[18-Apr-2021 01:33:32 UTC] tinyShield: incoming remote blocklist lookup: XX.XX.XX.XX

[18-Apr-2021 01:33:32 UTC] tinyShield: remote blocklist lookup response

[18-Apr-2021 01:33:32 UTC] tinyShield: Forbidden

[18-Apr-2021 01:34:38 UTC] tinyShield: incoming remote blocklist lookup: XX.XX.XX.XX

[18-Apr-2021 01:34:38 UTC] tinyShield: remote blocklist lookup response

[18-Apr-2021 01:34:38 UTC] tinyShield: Forbidden

[18-Apr-2021 01:34:53 UTC] tinyShield: incoming remote blocklist lookup: XX.XX.XX.XX

[18-Apr-2021 01:34:53 UTC] tinyShield: remote blocklist lookup response

[18-Apr-2021 01:34:53 UTC] tinyShield: Forbidden

[18-Apr-2021 13:40:39 UTC] tinyShield: incoming remote blocklist lookup: XX.XX.XX.XX

[18-Apr-2021 13:40:39 UTC] tinyShield: remote blocklist lookup response

[18-Apr-2021 13:40:39 UTC] tinyShield: {“subscription”:”community”,”action”:”allow”,”ip_address”:”XX.XX.XX.XX”,”rdns”:”XX.XX.XX.XX”,”geo_ip”:””,”is_tor_exit_node”:””}

[18-Apr-2021 13:57:51 UTC] tinyShield: incoming ip found in local allowlist and was allowed: XX.XX.XX.XX

[18-Apr-2021 13:57:51 UTC] tinyShield: incoming ip found in local allowlist and was allowed: XX.XX.XX.XX

[18-Apr-2021 15:35:50 UTC] tinyShield: incoming remote blocklist lookup: XX.XX.XX.XX

[18-Apr-2021 15:35:51 UTC] tinyShield: remote blocklist lookup response

[18-Apr-2021 15:35:51 UTC] tinyShield: {“subscription”:”community”,”action”:”allow”,”ip_address”:”XX.XX.XX.XX”,”rdns”:”XX.XX.XX.XX”,”geo_ip”:””,”is_tor_exit_node”:””}

[18-Apr-2021 15:35:52 UTC] tinyShield: incoming ip found in local allowlist and was allowed: XX.XX.XX.XX

[18-Apr-2021 15:35:52 UTC] tinyShield: incoming ip found in local allowlist and was allowed: XX.XX.XX.XX

[18-Apr-2021 15:35:57 UTC] tinyShield: incoming ip found in local allowlist and was allowed: XX.XX.XX.XX

This tells us all that’s been going on with tinyShield for as long as we’ve had this enabled. This is some important information, we can tell early on that there was a problem accessing the tinyShield servers, we were getting a “Forbidden” response. This was actually because the key that was being used was invalid. Once that was resolved, we can see that everything went back to normal.

Hope that helps!

Leave a Reply