better log initialization
Tyler Riddle [Thu, 13 Sep 2012 00:23:04 +0000 (17:23 -0700)]
lib/Object/Remote/Logging.pm [new file with mode: 0644]
lib/Object/Remote/ModuleLoader.pm
lib/Object/Remote/Role/Connector/PerlInterpreter.pm

diff --git a/lib/Object/Remote/Logging.pm b/lib/Object/Remote/Logging.pm
new file mode 100644 (file)
index 0000000..1839f22
--- /dev/null
@@ -0,0 +1,15 @@
+package Object::Remote::Logging;
+
+use strictures 1;
+
+use Log::Contextual::Routed qw( :log );
+use base qw(Log::Contextual::Routed); 
+
+sub get_parent_router { $_[0]->SUPER::get_parent_router }
+
+use Data::Dumper; 
+
+sub init_node { my $n = `hostname`; chomp($n); $_[0]->add_child_router("[node $n]", __PACKAGE__->get_root_router) }
+
+1;
+
index 2c9f98e..ebd1cb4 100644 (file)
@@ -18,13 +18,18 @@ BEGIN {
 
 use Moo;
 
+use Object::Remote::Logging qw( :log );
+
 has module_sender => (is => 'ro', required => 1);
 
 has inc_hook => (is => 'lazy');
 
 sub _build_inc_hook {
   my ($self) = @_;
-  Object::Remote::ModuleLoader::Hook->new(sender => $self->module_sender);
+  log_debug { "Constructing module builder hook" };
+  #TODO why didn't log_trace return the argument? 
+  logS_trace { "Done constructing module builder hook" }
+    Object::Remote::ModuleLoader::Hook->new(sender => $self->module_sender);
 }
 
 sub BUILD { shift->enable }
index ccbb74f..e041cc1 100644 (file)
@@ -5,6 +5,7 @@ use IO::Handle;
 use Object::Remote::ModuleSender;
 use Object::Remote::Handle;
 use Object::Remote::Future;
+use Object::Remote::Logging qw( :log );
 use Scalar::Util qw(blessed);
 use Moo::Role;
 
@@ -29,6 +30,8 @@ around connect => sub {
   return future {
     $f->on_done(sub {
       my ($conn) = $f->get;
+      $conn->remote_sub('Object::Remote::Logging::init_node')
+         ->(Object::Remote::Logging->get_router);
       Object::Remote::Handle->new(
         connection => $conn,
         class => 'Object::Remote::ModuleLoader',