Skip to content

Commit

Permalink
Sort hash keys when serializing references in log messages.
Browse files Browse the repository at this point in the history
This makes it much easier to find the data you are looking for.
  • Loading branch information
Ovid committed Mar 27, 2012
1 parent 7410e42 commit a558f12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Dancer/Logger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ sub _serialize {
->Terse(1)
->Purity(1)
->Indent(0)
->Sortkeys(1)
->Dump() :
$_
} @vars;
Expand Down
7 changes: 6 additions & 1 deletion t/11_logger/08_serialize.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Test::More import => ['!pass'];
plan skip_all => "Test::Output is needed for this test"
unless Dancer::ModuleLoader->load('Test::Output');

plan tests => 3;
plan tests => 4;

use Dancer ':syntax';
set logger => 'Console';
Expand All @@ -30,3 +30,8 @@ Test::Output::stderr_like(
'Multiple arguments are okay',
);

Test::Output::stderr_like(
sub { Dancer::Logger::warning( { b => 1, a => 2, e => 3, d => 4, c => 5}) },
qr/\[\d+\] warn @.+> {'a' => 2,'b' => 1,'c' => 5,'d' => 4,'e' => 3}/,
'Hash keys are sorted okay',
);

0 comments on commit a558f12

Please sign in to comment.