start adding logs and add support for routed logs and logging to stderr
[scpubgit/Object-Remote.git] / lib / Object / Remote / ModuleSender.pm
index 6fe0927..ae1f72c 100644 (file)
@@ -1,5 +1,6 @@
 package Object::Remote::ModuleSender;
 
+use Object::Remote::Logging qw( :log :dlog );
 use Config;
 use File::Spec;
 use List::Util qw(first);
@@ -11,22 +12,25 @@ sub _build_dir_list {
   my %core = map +($_ => 1), grep $_, @Config{
     qw(privlibexp archlibexp vendorarchexp sitearchexp)
   };
-  [ grep !$core{$_}, @INC ];
+  DlogS_trace { "dir list built in ModuleSender: $_" } [ grep !$core{$_}, @INC ];
 }
 
 sub source_for {
   my ($self, $module) = @_;
+  log_debug { "locating source for module '$module'" };
   if (my $find = Object::Remote::FromData->can('find_module')) {
     if (my $source = $find->($module)) {
-      return $source;
+      return Dlog_trace { "Object::Remote::FromData->find_module('$module') returned '$_'" } $source;
     }
   }
+  log_trace { "Searching for module in library directories" };
   my ($found) = first {  -f $_ }
                   map File::Spec->catfile($_, $module),
                     @{$self->dir_list};
   die "Couldn't find ${module} in remote \@INC. dir_list contains:\n"
       .join("\n", @{$self->dir_list})
     unless $found;
+  log_debug { "found '$module' at '$found'" };
   open my $fh, '<', $found or die "Couldn't open ${found} for ${module}: $!";
   return do { local $/; <$fh> };
 }