| 1 | # | ||||||||||
| 2 | # Sub::Contract::Debug - Guess once... | ||||||||||
| 3 | # | ||||||||||
| 4 | # $Id: Debug.pm,v 1.11 2009/06/16 12:23:58 erwan_lemonnier Exp $ | ||||||||||
| 5 | # | ||||||||||
| 6 | |||||||||||
| 7 | package Sub::Contract::Debug; | ||||||||||
| 8 | |||||||||||
| 9 | 23 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 23 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 23 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 23 | ▶ | use base qw(Exporter); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 23 | our $VERSION = '0.12'; | |||||||||
| 16 | |||||||||||
| 17 | 23 | our @EXPORT = (); | |||||||||
| 18 | 23 | our @EXPORT_OK = ('debug'); | |||||||||
| 19 | |||||||||||
| 20 | # to turn on debugging output in Sub::Contract, just | ||||||||||
| 21 | # set $DEBUG to more than 0: | ||||||||||
| 22 | |||||||||||
| 23 | 23 | my $DEBUG = 0; | |||||||||
| 24 | |||||||||||
| 25 | #--------------------------------------------------------------- | ||||||||||
| 26 | # | ||||||||||
| 27 | # debug - print a debug message to stdout | ||||||||||
| 28 | # | ||||||||||
| 29 | |||||||||||
| 30 | 127 | ▶ | sub debug { | ||||||||
|
Subroutine
debug: called CC=2 SCAR=10.9
Pod
documented
| |||||||||||
| 31 | 127 | my ($level,$text) = @_; | |||||||||
| 32 | |||||||||||
| 33 | 127 | ▶ | if ($level <= $DEBUG) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | chomp $text; | |||||||||
| 35 | 0 | my (undef, undef, $line) = caller(0); | |||||||||
| 36 | 0 | my (undef, undef, undef, $func) = caller(1); | |||||||||
| 37 | 0 | print "# DEBUG $func, l.".sprintf("%- 5s","$line:")." $text\n"; | |||||||||
| 38 | } | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 23 | 1; | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||