Skip to content

Commit

Permalink
Added debug from Dancer::Logger to output a log to the console.
Browse files Browse the repository at this point in the history
  • Loading branch information
gnusosa authored and xsawyerx committed Oct 17, 2012
1 parent 8790b2f commit c1f71f6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/Dancer/Script.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use Getopt::Long;
use Pod::Usage;
use LWP::UserAgent;
use constant FILE => 1;
set logger => 'console';

# subs
sub new {
Expand Down Expand Up @@ -286,8 +287,9 @@ sub safe_mkdir {
my $self = shift;
my $dir = shift;
if (not -d $dir) {
print "+ $dir\n";
mkpath $dir or die "could not mkpath $dir: $!";
debug ("Writing directory: $dir\n");
mkpath $dir or die "could not write the directory $dir: $!";
debug ("Sucesffully wrote the directory: $dir\n");
}
else {
print " $dir\n";
Expand All @@ -313,9 +315,10 @@ sub write_file {

my $fh;
my $content = $self->process_template($template, $vars);
print "+ $path\n";
debug ("Writing file: $path\n");
open $fh, '>', $path or die "unable to open file `$path' for writing: $!";
print $fh $content;
debug ("Sucesffully wrote: $path\n");
close $fh;
}

Expand All @@ -333,10 +336,12 @@ sub write_data_to_file {
my $self = shift;
my $data = shift;
my $path = shift;
debug ("Writing file: $path\n");
open(my $fh, '>', $path)
or warn "Failed to write file to $path - $!" and return;
binmode($fh);
print {$fh} unpack 'u*', $data;
debug ("Sucesffully wrote: $path\n");
close $fh;
return 1;
}
Expand Down

0 comments on commit c1f71f6

Please sign in to comment.