[Catalyst-commits] r14112 - in branches/Catalyst-Log-Log4perl/deprecated: . lib lib/MockApp lib/MockApp/Controller

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Tue Sep 27 17:54:48 GMT 2011


Author: t0m
Date: 2011-09-27 17:54:48 +0000 (Tue, 27 Sep 2011)
New Revision: 14112

Added:
   branches/Catalyst-Log-Log4perl/deprecated/10-basic.t
   branches/Catalyst-Log-Log4perl/deprecated/20-test-log4perl.t
   branches/Catalyst-Log-Log4perl/deprecated/21-test-log4perl-hotfix.t
   branches/Catalyst-Log-Log4perl/deprecated/22-test-log4perl-hotfix-broken.t
   branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp.pm
   branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/
   branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/Controller/
   branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/Controller/Root.pm
Removed:
   branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/Controller/
   branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/Controller/Root.pm
Log:
svn merge -r 14100:14099 t/

Copied: branches/Catalyst-Log-Log4perl/deprecated/10-basic.t (from rev 14099, trunk/Catalyst-Log-Log4perl/t/10-basic.t)
===================================================================
--- branches/Catalyst-Log-Log4perl/deprecated/10-basic.t	                        (rev 0)
+++ branches/Catalyst-Log-Log4perl/deprecated/10-basic.t	2011-09-27 17:54:48 UTC (rev 14112)
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use FindBin;
+
+use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
+
+
+use Catalyst::Test 'MockApp';
+
+use Test::More tests => 11;
+
+
+# fetch the single appender so we can access log messages
+my ($appender) = values %{ Log::Log4perl->appenders };
+isa_ok( $appender, 'Log::Log4perl::Appender' );
+
+sub log_ok($;$) {
+    my ( $check, $msg ) = @_;
+    is( $appender->string, $check, $msg );
+    $appender->string('');
+}
+
+sub log_like($;$) {
+    my ( $re, $msg ) = @_;
+    like( $appender->string, $re, $msg );
+    $appender->string('');
+}
+
+## test capturing of log messages
+my $c;
+$c = get('/foo');
+is( $c, 'foo', 'Foo response body' );
+log_ok( '[MockApp.Controller.Root] root/foo', 'Foo log message' );
+
+$c = get( '/bar?say=hello' );
+is( $c, 'hello', 'Bar response body' );
+log_ok( '[MockApp.Controller.Root] root/bar', 'Bar log message' );
+
+## test different cseps
+
+# %F File where the logging event occurred
+
+$appender->layout( Log::Log4perl::Layout::PatternLayout->new('%F') );
+$c = get('/foo');
+log_like( qr|lib/MockApp/Controller/Root.pm$|, 'Loggin filepath' );
+
+$appender->layout( Log::Log4perl::Layout::PatternLayout->new('%L') );
+$c = get('/foo');
+log_ok( '16', 'Loggin line number' );
+
+# %C Fully qualified package (or class) name of the caller
+
+$appender->layout( Log::Log4perl::Layout::PatternLayout->new('%C') );
+$c = get('/foo');
+log_ok( 'MockApp::Controller::Root', 'Loggin class name' );
+
+# %l Fully qualified name of the calling method followed by the
+#    callers source the file name and line number between
+#    parentheses.
+
+$appender->layout( Log::Log4perl::Layout::PatternLayout->new('%l') );
+$c = get('/foo');
+log_like
+qr|^MockApp::Controller::Root::foo .*lib/MockApp/Controller/Root.pm \(16\)$|,
+  'Loggin location';
+
+# %M Method or function where the logging request was issued
+
+$appender->layout( Log::Log4perl::Layout::PatternLayout->new('%M') );
+$c = get('/foo');
+log_ok( 'MockApp::Controller::Root::foo', 'Loggin method' );
+
+# %T A stack trace of functions called
+
+# unimplemented: would cause a major performance hit
+
+## check another log message to ensure the closures work correctly
+
+$appender->layout( Log::Log4perl::Layout::PatternLayout->new('%L') );
+$c = get('/bar');
+log_ok( '22', 'Loggin another line number' );

Copied: branches/Catalyst-Log-Log4perl/deprecated/20-test-log4perl.t (from rev 14099, trunk/Catalyst-Log-Log4perl/t/20-test-log4perl.t)
===================================================================
--- branches/Catalyst-Log-Log4perl/deprecated/20-test-log4perl.t	                        (rev 0)
+++ branches/Catalyst-Log-Log4perl/deprecated/20-test-log4perl.t	2011-09-27 17:54:48 UTC (rev 14112)
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
+
+use Catalyst::Test 'MockApp';
+use Test::More;
+
+BEGIN {
+  eval "use Test::Log4perl;";
+  if ($@) {
+    plan skip_all => 'Test::Log4perl required for testing logging';
+  } else {
+    plan tests => 2;
+  }
+}
+
+my $tlogger = Test::Log4perl->get_logger("MockApp.Controller.Root");
+
+TODO: {
+  local $TODO = 'First request without prev. get_logger fails';
+  Test::Log4perl->start();
+  $tlogger->warn ("root/foo");
+  get('/foo');
+  Test::Log4perl->end('Got all log messages');
+}
+
+Test::Log4perl->start();
+$tlogger->warn ("root/foo");
+get('/foo');
+Test::Log4perl->end('The second request send all log messages');
+
+

Copied: branches/Catalyst-Log-Log4perl/deprecated/21-test-log4perl-hotfix.t (from rev 14099, trunk/Catalyst-Log-Log4perl/t/21-test-log4perl-hotfix.t)
===================================================================
--- branches/Catalyst-Log-Log4perl/deprecated/21-test-log4perl-hotfix.t	                        (rev 0)
+++ branches/Catalyst-Log-Log4perl/deprecated/21-test-log4perl-hotfix.t	2011-09-27 17:54:48 UTC (rev 14112)
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
+
+use Catalyst::Test 'MockApp';
+use Test::More;
+
+BEGIN {
+  eval "use Test::Log4perl;";
+  if ($@) {
+    plan skip_all => 'Test::Log4perl required for testing logging';
+  } else {
+    plan tests => 1;
+  }
+}
+
+my $tlogger = Test::Log4perl->get_logger("MockApp.Controller.Root");
+Log::Log4perl->get_logger("MockApp.Controller.Root");
+
+Test::Log4perl->start();
+$tlogger->warn("root/foo");
+get('/foo');
+Test::Log4perl->end('Got log messages after initial get_logger call');
+
+

Copied: branches/Catalyst-Log-Log4perl/deprecated/22-test-log4perl-hotfix-broken.t (from rev 14099, trunk/Catalyst-Log-Log4perl/t/22-test-log4perl-hotfix-broken.t)
===================================================================
--- branches/Catalyst-Log-Log4perl/deprecated/22-test-log4perl-hotfix-broken.t	                        (rev 0)
+++ branches/Catalyst-Log-Log4perl/deprecated/22-test-log4perl-hotfix-broken.t	2011-09-27 17:54:48 UTC (rev 14112)
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" );
+
+use Catalyst::Test 'MockApp';
+use Test::More;
+
+BEGIN {
+  eval "use Test::Log4perl;";
+  if ($@) {
+    plan skip_all => 'Test::Log4perl required for testing logging';
+  } else {
+    plan tests => 2;
+  }
+}
+
+my $tlogger = Test::Log4perl->get_logger("MockApp.Controller.Root");
+Log::Log4perl->get_logger("MockApp");
+
+TODO: {
+  local $TODO = 'First request with get_logger in root category fails';
+  Test::Log4perl->start();
+  $tlogger->warn ("root/foo");
+  get('/foo');
+  Test::Log4perl->end('Got all log messages');
+}
+
+Test::Log4perl->start();
+$tlogger->warn ("root/foo");
+get('/foo');
+Test::Log4perl->end('The second request send all log messages');
+
+

Deleted: branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/Controller/Root.pm
===================================================================
--- trunk/Catalyst-Log-Log4perl/t/lib/MockApp/Controller/Root.pm	2011-09-20 20:00:18 UTC (rev 14099)
+++ branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/Controller/Root.pm	2011-09-27 17:54:48 UTC (rev 14112)
@@ -1,26 +0,0 @@
-package MockApp::Controller::Root;
-
-use strict;
-use warnings;
-
-use base qw/Catalyst::Controller/;
-
-__PACKAGE__->config->{namespace} = '';
-
-sub auto : Private {
-    my ( $self, $c ) = @_;
-}
-
-sub foo : Local {
-    my ( $self, $c ) = @_;
-    $c->log->warn('root/foo');
-    $c->response->body('foo');
-}
-
-sub bar : Local {
-    my ( $self, $c ) = @_;
-    $c->log->warn('root/bar');
-    $c->response->body( $c->request->param('say') );
-}
-
-1;

Copied: branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/Controller/Root.pm (from rev 14099, trunk/Catalyst-Log-Log4perl/t/lib/MockApp/Controller/Root.pm)
===================================================================
--- branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/Controller/Root.pm	                        (rev 0)
+++ branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp/Controller/Root.pm	2011-09-27 17:54:48 UTC (rev 14112)
@@ -0,0 +1,26 @@
+package MockApp::Controller::Root;
+
+use strict;
+use warnings;
+
+use base qw/Catalyst::Controller/;
+
+__PACKAGE__->config->{namespace} = '';
+
+sub auto : Private {
+    my ( $self, $c ) = @_;
+}
+
+sub foo : Local {
+    my ( $self, $c ) = @_;
+    $c->log->warn('root/foo');
+    $c->response->body('foo');
+}
+
+sub bar : Local {
+    my ( $self, $c ) = @_;
+    $c->log->warn('root/bar');
+    $c->response->body( $c->request->param('say') );
+}
+
+1;

Copied: branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp.pm (from rev 14099, trunk/Catalyst-Log-Log4perl/t/lib/MockApp.pm)
===================================================================
--- branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp.pm	                        (rev 0)
+++ branches/Catalyst-Log-Log4perl/deprecated/lib/MockApp.pm	2011-09-27 17:54:48 UTC (rev 14112)
@@ -0,0 +1,24 @@
+package MockApp;
+
+use strict;
+use warnings;
+
+use base qw/Catalyst/;
+
+use Catalyst::Log::Log4perl;
+
+our %config = ( name => 'MockApp', home => './t/' );
+sub config { \%config }
+
+__PACKAGE__->log(
+    Catalyst::Log::Log4perl->new( \<<CONF, override_cspecs => 1 ) );
+log4perl.rootLogger=WARN, LOG
+log4perl.appender.LOG=Log::Log4perl::Appender::String
+log4perl.appender.LOG.layout=PatternLayout
+log4perl.appender.LOG.layout.ConversionPattern=[%c] %m
+CONF
+
+
+__PACKAGE__->setup();
+
+1;




More information about the Catalyst-commits mailing list