HeartInternet Hostpay Error Logs Empty

Ok, so Heartinternet do some cool things, but they also do some stupidly annoying things too.

Like when you are integrating hostpay, any glance at the error log will tell you nothing, because they are empty… Well. Extend shows the hostpay error logs empty. But they are not, hostpay just can’t open the log files directory.

One way to view error logs when developing hostpay, is by using a Perl script and running it in your browser (i know, but heart cant tell me why either… it transpires: because i have rewriteRules in a .htaccess file, i need to disable this (!) then view the error log, and then re-enable my .htaccess file! – Really?

My notes below the code explain the reasons behind this.

Essentially all we need to do is open up ../logs and grab files ending n -error_log, and tail them using the system command. This could also be achieved in php but haven’t tried, I defaulted to Perl because I was in cgi land. So, the Perl required is:

[code]
#!/usr/bin/perl -w
use strict;
print "Content-Type: text/plain\n\n";
if ( -d "../logs" )
{
chdir "../logs" or die print "$!\n";
for my $n (glob("*-error_log"))
{
system("tail", "-200", $n);
}
}
[/code]

Save the Perl script above in a file, say error_log.cgi and just view it in your browser, and merrily view the error log without having to rename .htaccess files every time.

Why rewrite rules show the hostpay error logs empty

The reason for having to rename or remove the .htaccess file (containing the rewrite rules) before viewing logs is this:

Heart have their logs set up in /var/log/virtual_logs and then put a symlink in all of our web roots, called “logs”, which is a symbolic link to /var/log/virtual_logs, of course.

So when the rewrite conditions and rules required for hostpay are in place, they rewrite the path to the logs (forcing all requests to go through index.cgi), therefore breaking it. Even viewing through the extend panel shows empty logs.




No Comments


No comments yet.



Leave a Reply

Your email address will not be published. Required fields are marked *