Tripletail
view release on metacpan or search on metacpan
lib/Tripletail/Debug.pm view on Meta::CPAN
# -----------------------------------------------------------------------------
# Tripletail::Debug - TL ãããã°ç¨ã¯ã©ã¹
# -----------------------------------------------------------------------------
package Tripletail::Debug;
use strict;
use warnings;
use Data::Dumper ();
use Tripletail;
sub _INIT_HOOK_PRIORITY() { 1_000_000_000 }; # é åºã¯åããªãã
sub _PRE_REQUEST_HOOK_PRIORITY() { 1_000_000_000 } # æå¾ã§ãªããã°ãªããªãã
sub _OUTPUT_FILTER_PRIORITY() { 1_000_000_000 } # æå¾ã§ãªããã°ãªããªãã
our $_INSTANCE;
1;
sub _getInstance {
my $class = shift;
if(!$_INSTANCE) {
$_INSTANCE = $class->__new(@_);
}
$_INSTANCE;
}
sub __new {
my $class = shift;
my $group = shift;
my $this = bless {} => $class;
$this->{group} = defined $group ? $group : 'Debug';
$this->{enabled} = $TL->INI->get($this->{group} => enable_debug => undef);
$this->{popup_type} = $TL->INI->get($this->{group} => 'popup_type', 'none');
$this->{warn_logging} = $TL->INI->get($this->{group} => 'warn_logging', 1);
$this->{warn_popup} = $TL->INI->get($this->{group} => 'warn_popup', 1);
$this->{log_popup} = $TL->INI->get($this->{group} => 'log_popup', 1);
$this->{request_logging} = $TL->INI->get($this->{group} => 'request_logging', 1);
$this->{request_popup} = $TL->INI->get($this->{group} => 'request_popup', 1);
$this->{request_logging_max} = $TL->parseQuantity($TL->INI->get($this->{group} => 'request_logging_max', 0));
$this->{content_logging} = $TL->INI->get($this->{group} => 'content_logging', 1);
$this->{content_popup} = $TL->INI->get($this->{group} => 'content_popup', 1);
$this->{content_logging_max} = $TL->parseQuantity($TL->INI->get($this->{group} => 'content_logging_max', 0));
$this->{content_popup_max} = $TL->parseQuantity($TL->INI->get($this->{group} => 'content_popup_max', 0));
$this->{template_logging} = $TL->INI->get($this->{group} => 'template_logging', 1);
$this->{template_popup} = $TL->INI->get($this->{group} => 'template_popup', 1);
$this->{db_logging} = $TL->INI->get($this->{group} => 'db_logging', 1);
$this->{db_popup} = $TL->INI->get($this->{group} => 'db_popup', 1);
$this->{db_logging_level} = $TL->INI->get($this->{group} => 'db_logging_level', 1);
$this->{db_profile} = $TL->INI->get($this->{group} => 'db_profile', 1);
$this->{location_debug} = $TL->INI->get($this->{group} => 'location_debug', 0);
$this->reset;
if($this->{enabled}) {
# æå¾ã«å¼ã°ããpreRequestãã³ãã©ãç»é²ã
$TL->setHook(
'preRequest',
_PRE_REQUEST_HOOK_PRIORITY,
sub {
if($this->{request_logging}) {
$this->__log_request;
}
},
);
# æåã«å¼ã°ããinitãã³ãã©ãç»é²ã
$TL->setHook(
'init',
_INIT_HOOK_PRIORITY,
sub {
# èªåèªèº«ãContentFilterã¨ãã¦ç»é²ã
$TL->setContentFilter(
[__PACKAGE__, _OUTPUT_FILTER_PRIORITY], this => $this
);
},
);
if($this->{warn_logging} or $this->{warn_popup}) {
$SIG{__WARN__} = sub {
my $msg = shift;
Tripletail::_isa($msg, 'Tripletail::Error') or $msg = $TL->newError(warn => $msg);
( run in 0.811 second using v1.01-cache-2.11-cpan-98e64b0badf )