Skip to content

Commit

Permalink
Merge branch 'review/hobbestigrou' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Sukrieh committed Feb 5, 2011
2 parents 692aa24 + 516d89f commit 3170c75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/Dancer/Logger/File.pm
Expand Up @@ -11,8 +11,9 @@ use IO::File;

sub logdir {
my $appdir = setting('appdir');
my $altpath = setting('log_path');
my $logroot = $appdir || File::Spec->tmpdir();
return path($logroot, 'logs');
return ($altpath ? $altpath : path($logroot, 'logs'));
}

sub init {
Expand Down Expand Up @@ -72,7 +73,9 @@ file.
=head2 logdir
Returns the log directory, decided by "logs" either in "appdir" setting or in a
temp directory.
temp directory. It's also possible to specify a logs directory with the log_path option.
setting log_path => $dir;
=head2 _log
Expand Down
15 changes: 13 additions & 2 deletions t/11_logger/03_file.t
@@ -1,4 +1,4 @@
use Test::More tests => 9, import => ['!pass'];
use Test::More tests => 14, import => ['!pass'];

use strict;
use warnings;
Expand Down Expand Up @@ -27,5 +27,16 @@ ok($l->debug("Perl Dancer test message 2/4"), "debug works");
ok($l->warning("Perl Dancer test message 3/4"), "warning works");
ok($l->error("Perl Dancer test message 4/4"), "error works");

#Create a new tmp directory to test log_path option
my $dir2 = tempdir(CLEANUP => 1);
setting log_path => $dir2;

is(Dancer::Logger::File->logdir, $dir2,
"logir is ok");

ok($l->_log(debug => "Perl Dancer test message with log_path setting"), "_log works");
ok($l->debug("Perl Dancer test message with log_path setting 2/4"), "debug works");
ok($l->warning("Perl Dancer test message with log_path setting 3/4"), "warning works");
ok($l->error("Perl Dancer test message with log_path setting 4/4"), "error works");

$l->{fh}->close;
File::Temp::cleanup();

0 comments on commit 3170c75

Please sign in to comment.