| 1 | package Gapp::App::Debug; | ||
| 2 | { | ||
| 3 | $Gapp::App::Debug::VERSION = '0.007'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use Moose; | ||
| 7 | use Sub::Exporter; | ||
| 8 | |||
| 9 | our $DEBUG = 0; | ||
| 10 | |||
| 11 | use DateTime; | ||
| 12 | |||
| 13 | Sub::Exporter::setup_exporter({ | ||
| 14 | exports => [qw( debug )], | ||
| 15 | groups => { all => [qw( debug )] } | ||
| 16 | }); | ||
| 17 | |||
| 18 | |||
| 19 | sub debug { | ||
| 20 | my ( $message, $opts ) = @_; | ||
| 21 | $opts ||= {}; | ||
| 22 | |||
| 23 | # only if we are set to debug | ||
| 24 | if ( $opts->{debug} || $DEBUG || $ENV{DEBUG} ) { | ||
| 25 | |||
| 26 | print q([D] ), $message, qq[\n]; | ||
| 27 | |||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; | ||
| 32 | |||
| 33 | __END__ |