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;
return $hook ? $hook->sender : Object::Remote::ModuleSender->new;
}
+has perl_command => (is => 'lazy');
+
+sub _build_perl_command { [ 'perl', '-' ] }
+
around connect => sub {
my ($orig, $self) = (shift, shift);
my $f = $self->$start::start($orig => @_);
return future {
$f->on_done(sub {
my ($conn) = $f->get;
+ my $sub = $conn->remote_sub('Object::Remote::Logging::init_logging_forwarding');
+ $sub->('Object::Remote::Logging', Object::Remote::Logging->arg_router);
Object::Remote::Handle->new(
connection => $conn,
class => 'Object::Remote::ModuleLoader',
} 2;
};
-sub _perl_command { 'perl', '-' }
+sub final_perl_command { shift->perl_command }
sub _start_perl {
my $self = shift;
my $pid = open2(
my $foreign_stdout,
my $foreign_stdin,
- $self->_perl_command(@_),
+ @{$self->final_perl_command},
) or die "Failed to run perl at '$_[0]': $!";
return ($foreign_stdin, $foreign_stdout, $pid);
}
$text .= "ENDFAT\n";
$text .= <<'END';
eval $Object::Remote::FatNode::DATA;
+die $@ if $@;
END
$text .= "__END__\n";
return $text;