/usr/share/perl5/Text/MicroMason/Debug.pm is in libtext-micromason-perl 2.21-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | package Text::MicroMason::Debug;
use strict;
use Carp;
######################################################################
use vars qw( %Defaults );
sub defaults {
(shift)->NEXT('defaults'), debug => { default => 1 },
}
######################################################################
sub debug_msg {
my $self = shift;
my $type = shift;
my $flag = ( ! ref $self->{debug} ) ? $self->{debug} :
exists( $self->{debug}{$type} ) ? $self->{debug}{$type} :
$self->{debug}{'default'};
if ( $flag ) {
warn "MicroMason Debug $type: " . ( ( @_ == 1 ) ? $_[0] : join( ', ', map Text::MicroMason::Base::_printable(), @_ ) ) . "\n";
}
wantarray ? @_ : $_[0];
}
######################################################################
sub new {
my $self = shift;
$self->debug_msg( 'new', $self, @_ );
$self->NEXT( 'new', @_ );
}
sub create {
my $self = (shift)->NEXT( 'create', @_ );
$self->debug_msg( 'create', ref($self), %$self );
return $self;
}
sub prepare {
my ( $self, $src_type, $src_data ) = @_;
my @result = $self->NEXT( 'prepare', $src_type, $src_data );
if ( scalar @result > 3 or grep { $result[$_] ne $_[$_] } 0 .. 2 ){
$self->debug_msg( 'prepare', @result );
}
return @result;
}
sub interpret {
my $self = shift;
$self->debug_msg( 'interpret', @_ );
$self->NEXT( 'interpret', @_ )
}
# $contents = $mason->read_file( $filename );
sub read_file {
my $self = shift;
$self->debug_msg( 'read', "Opening file '$_[0]'" );
$self->NEXT( 'read_file', @_ )
}
sub lex {
my $self = shift;
$self->debug_msg( 'source', @_ );
$self->debug_msg( 'lex', $self->NEXT( 'lex', @_ ) );
}
sub assemble {
my $self = shift;
$self->debug_msg( 'assemble', $self->NEXT( 'assemble', @_ ) );
}
sub eval_sub {
my $self = shift;
$self->debug_msg( 'eval', @_ );
$self->NEXT( 'eval_sub', @_ )
}
######################################################################
1;
__END__
######################################################################
=head1 NAME
Text::MicroMason::Debug - Provide developer info via warn
=head1 SYNOPSIS
Instead of using this class directly, pass its name to be mixed in:
use Text::MicroMason;
my $mason = Text::MicroMason->new( -Debug );
Use the standard compile and execute methods to parse and evaluate templates:
print $mason->compile( text=>$template )->( @%args );
print $mason->execute( text=>$template, @args );
You'll see lots of warning output on STDERR:
MicroMason Debug create: Text::MicroMason::Base::AUTO::Debug...
MicroMason Debug source: q(Hello <% $noun %>!)
MicroMason Debug lex: text, q(Hello ), expr, q( $noun ), text, q(!)
MicroMason Debug eval: sub { my @OUT; my $_out = sub { push ...
=head1 DESCRIPTION
This package provides numerous messages via warn for developer use when debugging templates built with Text::MicroMason.
=head2 Supported Attributes
=over 4
=item debug
Activates debugging messages for many methods. Defaults to logging everything.
Can be set to 0 or 1 to log nothing or everything.
Alternately, set this to a hash reference containing values for the steps you are interested in to only log this items:
debug => { source => 1, eval => 1 }
You can also selectively suppress some warnings:
debug => { default => 1, source => 0, eval => 0 }
=back
=head2 Private Methods
=over 4
=item debug_msg
Called to provide a debugging message for developer reference. No output is produced unless the object's 'debug' flag is true.
=back
=head1 SEE ALSO
For an overview of this templating framework, see L<Text::MicroMason>.
This is a mixin class intended for use with L<Text::MicroMason::Base>.
For distribution, installation, support, copyright and license
information, see L<Text::MicroMason::Docs::ReadMe>.
=cut
|