From 2cb268a0645d6bf4cf90a3ecceca45f26546b6a7 Mon Sep 17 00:00:00 2001 From: Arthur Axel 'fREW' Schmidt Date: Thu, 3 Jul 2014 23:32:21 -0500 Subject: [PATCH] Fix stacktrace option (T) --- Changes | 1 + lib/DBIx/Class/UnicornLogger.pm | 1 + t/structured.t | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/Changes b/Changes index ac7a7a3..2e61110 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for {{$dist->name}} {{$NEXT}} + - Fix stacktrace option (T) - Fix warning coming from SQL::Abstract::Tree 0.001002 2013-03-02 10:31:56 CST6CDT diff --git a/lib/DBIx/Class/UnicornLogger.pm b/lib/DBIx/Class/UnicornLogger.pm index 82c2857..96c5a1d 100644 --- a/lib/DBIx/Class/UnicornLogger.pm +++ b/lib/DBIx/Class/UnicornLogger.pm @@ -22,6 +22,7 @@ my %code_to_method = ( p => 'log_priority', r => 'log_milliseconds_since_start', R => 'log_milliseconds_since_last_log', + T => 'log_stacktrace', ); sub BUILDARGS { diff --git a/t/structured.t b/t/structured.t index 4223650..dd4f301 100644 --- a/t/structured.t +++ b/t/structured.t @@ -61,4 +61,34 @@ use DBIx::Class::UnicornLogger; like $lines[2], qr/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] WHERE id = '1'/; } +{ + my $cap; + open my $fh, '>', \$cap; + + my $pp = DBIx::Class::UnicornLogger->new({ + squash_repeats => 1, + tree => { + profile => 'console_monochrome', + fill_in_placeholders => 1, + placeholder_surround => ['', ''], + }, + format => "%T%n%m", + multiline_format => '%m', + show_progress => 0, + }); + + $pp->debugfh($fh); + + $pp->query_start('SELECT * FROM frew WHERE id = ?', q('1')); + # should do nothing + $pp->query_end('SELECT * FROM frew WHERE id = ?', q('1')); + + my @lines = split /\n/, $cap; + + like $lines[-4], qr/structured\.t/; + like $lines[-3], qr/SELECT \* /; + like $lines[-2], qr/ FROM frew /; + like $lines[-1], qr/WHERE id = '1'/; +} + done_testing();