package Debug;
##############################################################
# デバッグ用ツール umino@uic.jp
#
# my $DEBUG = { mode_name => 'debug', cookie_name => 'debug', password => 'dpass' };
# my %DCKI = $cgi->cookie($DEBUG->{cookie_name});
# $DBG->{_flag} = 1 if $DCKI{password} eq $DEBUG->{password};
# if($ENV{MOD_PERL}) { *CORE::GLOBAL::exit = sub { print debug($DBG); &Apache::exit } }
# else { *exit = sub { print debug($DBG); CORE::exit } }
# print debug_set($DEBUG, { exec => $FRM{exec}, expires => $FRM{expires}, password => $FRM{password} }) and exit if exists $FRM{$DEBUG->{mode_name}};
##############################################################
use strict;
use CGI;
use Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);
@EXPORT = qw(show_debug debug_set);
;################################
;# init_debug
;################################
sub init_debug
{
my $dbg = shift;
my $flg = shift;
my $bnc = shift;
if($ENV{MOD_PERL}) { *CORE::GLOBAL::exit = sub { print show_debug({variable => $dbg, flag => $flg, bench => $bnc}); \&Apache::exit } }
else { *::exit = sub { print show_debug({variable => $dbg, flag => $flg, bench => $bnc}); CORE::exit } }
return;
}
;################################
;# debug
;################################
sub show_debug
{
my $argv = shift;
my $DBG = $argv->{variable};
my $BNC = $argv->{bench};
my ($DEF, @date, $print_date, $out_put);
return if !$argv->{flag};
my $con = -t STDOUT ? 1 : 0;
### ヘッダー
if ($con) {
$out_put .= '-' x 50 . "\n";
$out_put .= "Debug mode\n";
$out_put .= '-' x 50 . "\n";
$out_put .= "File info\n";
} else {
$out_put .= "\n
\n";
$out_put .= qq|
\n|;
$out_put .= "\n"; $out_put .= qq|\n|; $out_put .= qq| |