CGI-Lazy
view release on metacpan or search on metacpan
lib/CGI/Lazy/Utility/Debug.pm view on Meta::CPAN
package CGI::Lazy::Utility::Debug;
use strict;
use Data::Dumper;
use File::Basename;
#-------------------------------------------------------------------------------------------------------------------------------
sub cookie {
my $self = shift;
my $q = $self->q;
print $q->header,
$q->start_html({-title => 'CGI Test Page'}),
$q->h1('Cookies'),
$q->table($q->th('Param'), $q->th('Value'),
map {
$q->TR($q->th({-style => "text-align:center"}, $_), $q->td({-style => "text-align:center"}, $q->cookie($_)))
} $q->cookie()
);
}
#-------------------------------------------------------------------------------------------------------------------------------
sub config {
my $self = shift;
return $self->q->config;
}
#-------------------------------------------------------------------------------------------------------------------------------
sub defaultFile {
my $self = shift;
return $self->{_defaultFile};
}
#-------------------------------------------------------------------------------------------------------------------------------
sub dump {
my $self = shift;
my $fulloutput = "<div id='debug'>\n";
foreach my $thing (@_) {
if (ref $thing) {
my $output = Dumper($thing);
$output =~ s/\n/<br>/g;
$output =~ s/ / /g;
$output =~ s/\t/   /g;
$fulloutput .= $output;
} else {
$fulloutput .= $thing;
}
}
$fulloutput .= "\n</div>";
return $fulloutput;
}
#-------------------------------------------------------------------------------------------------------------------------------
sub edump {
my $self = shift;
my $filename = $self->config->debugfile;
$filename = $self->defaultFile unless $filename;
open OF, ">> /tmp/$filename" or $self->q->errorHandler->couldntOpenDebugFile($filename, $!);
local $\=$/;
print OF '-'x20 . $self->timestamp() . '-'x20;
foreach my $thing (@_) {
( run in 0.777 second using v1.01-cache-2.11-cpan-5837b0d9d2c )