| 1 | package MYDan::Util::Debug; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | MYDan::Util::Debug | ||
| 6 | |||
| 7 | =cut | ||
| 8 | use warnings; | ||
| 9 | use strict; | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | use MYDan::Util::Debug; | ||
| 14 | |||
| 15 | MYDan::Util::Debug->isdebug( 1 ); | ||
| 16 | |||
| 17 | =head1 Methods | ||
| 18 | |||
| 19 | =head3 isdebug( $level ) | ||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | sub isdebug | ||
| 24 | { | ||
| 25 | my ( $class, $level ) = splice @_; | ||
| 26 | $level = 1 unless $level && $level =~ /^\d+$/; | ||
| 27 | |||
| 28 | my $env = $ENV{MYDan_DEBUG}; | ||
| 29 | $env = 0 unless $env && $env =~ /^\d+$/; | ||
| 30 | |||
| 31 | return $env >= $level ? 1 : 0; | ||
| 32 | } | ||
| 33 | |||
| 34 | |||
| 35 | 1; |