[ic] custom logging

Richard Templet richard at endpoint.com
Mon May 5 14:46:16 UTC 2014


On Fri, May 02, 2014 at 02:42:58PM -0500, David Etheredge wrote:
> I want to add some custom logging to each of my sites that run interchange.
> 
> I have been doing this on some other sites with a perl based cgi. Is
> there a good place in the cart.cgi to add this where this log can be
> written?
> 
> The log file is written with the following:  localtime()
> $ENV{'REMOTE_ADDR'}  $ENV{'HTTP_REFERER'})   Query String
> Affiliate_ID(if any)  subject(if any) ;
> I prefer to keep this separate from other logs as I use it to keep
> PPC and Affiliate programs honest which requires that I sort the
> list.
> 
> 
> 
> Some example entries:
> 
> Fri May 2 02:50:48 2014 21.37.47.57 http://www.google.com/url?sa=t&rct=j&q=parasite%20zapper%20buy&source=web&cd=10&ved=0CEsQFjAJ&url=http%3A%2F%2Fparadevices.com%2F
> 
> Fri May 2 03:27:20 2014 28.46.65.83
> http://huldaclarkparazapper.com/cgi-bin/cart.cgi?mv_pc=Gads
> 
> Fri May 2 08:45:17 2014 26.53.61.87
> http://huldaclarkparazapper.com/cgi-bin/cart.cgi?mv_pc=exseek
> 
> Fri May 2 12:12:48 2014 28.425.63.87
> http://www.bing.com/search?q=zapper&FORM=IE8SRC&adlt=strict
> 
> 
> 

We normally do this as a Global UserTag and call it from within Interchange.


sub fancy_logging { 
    my ($filename, $data ) = @_; 
    my $path = "/home/$user/interchange/var/log/$filename";
    open (FILE, ">>$path");
    print FILE $data;
    close FILE;
    return; 
}

This allows us to do things like [fancy_logging filename="checkout.txt" data="[scratch stuffs]"] on any page and it'll put the data into the checkout.txt file. An additional benefit of doing this instead of something like logDebug is you can rotate the using logrotate and not have to worry about restarting Interchange.

There is also a log tag that you can use as well that might fit the bill.

HTH,


Richard Templet
End Point Corporation




More information about the interchange-users mailing list