From: Tyler Riddle Date: Thu, 13 Sep 2012 00:23:04 +0000 (-0700) Subject: better log initialization X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3a966220ab1c15c63dcac5002bdd175cf70deaa8;p=scpubgit%2FObject-Remote.git better log initialization --- diff --git a/lib/Object/Remote/FatNode.pm b/lib/Object/Remote/FatNode.pm index d76a21d..0d67a98 100644 --- a/lib/Object/Remote/FatNode.pm +++ b/lib/Object/Remote/FatNode.pm @@ -40,10 +40,11 @@ chomp(my @inc = qx($command)); my %mods = reverse @inc; +#TODO oi this isn't right yet my @non_core_non_arch = grep +( not ( /^\Q$Config{privlibexp}/ or /^\Q$Config{archlibexp}/ - or /^\Q$Config{vendorarchexp}/ or /^\Q$Config{sitearchexp}/ + #or /^\Q$Config{vendorarchexp}/ or /^\Q$Config{sitearchexp}/ ) ), keys %mods; diff --git a/lib/Object/Remote/Logging.pm b/lib/Object/Remote/Logging.pm new file mode 100644 index 0000000..1839f22 --- /dev/null +++ b/lib/Object/Remote/Logging.pm @@ -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; + diff --git a/lib/Object/Remote/ModuleLoader.pm b/lib/Object/Remote/ModuleLoader.pm index 2c9f98e..ebd1cb4 100644 --- a/lib/Object/Remote/ModuleLoader.pm +++ b/lib/Object/Remote/ModuleLoader.pm @@ -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 } diff --git a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm index ccbb74f..e041cc1 100644 --- a/lib/Object/Remote/Role/Connector/PerlInterpreter.pm +++ b/lib/Object/Remote/Role/Connector/PerlInterpreter.pm @@ -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',