start adding logs and add support for routed logs and logging to stderr
[scpubgit/Object-Remote.git] / lib / Object / Remote / Handle.pm
index 1a757ab..a3cf33a 100644 (file)
@@ -3,6 +3,10 @@ package Object::Remote::Handle;
 use Object::Remote::Proxy;
 use Scalar::Util qw(weaken blessed);
 use Object::Remote::Future;
+#must find way to exclude certain log events
+#from being forwarded - log events generated in
+#response to log events cause exploding
+#use Object::Remote::Logging qw(:log);
 use Module::Runtime qw(use_module);
 use Moo;
 
@@ -27,18 +31,22 @@ sub proxy {
 
 sub BUILD {
   my ($self, $args) = @_;
-  unless ($self->id) {
+#  log_debug { "constructing instance of " . ref($self) };
+  if ($self->id) {
+    $self->disarm_free;
+  } else {
     die "No id supplied and no class either" unless $args->{class};
     ref($_) eq 'HASH' and $_ = [ %$_ ] for $args->{args};
     $self->_set_id(
       await_future(
-        $self->connection->send(
-          class_call => $args->{class}, 0,
+        $self->connection->send_class_call(
+          0, $args->{class},
           $args->{constructor}||'new', @{$args->{args}||[]}
         )
       )->{remote}->disarm_free->id
     );
   }
+#  log_trace { "finished constructing " . ref($self) };
   $self->connection->register_remote($self);
 }