1 #This is an experimental method for working with
2 #Log::Contextual crossing Object::Remote connections
5 package Object::Remote::Role::LogForwarder;
8 use Object::Remote::Logging;
9 use Scalar::Util qw(weaken);
12 with 'Log::Contextual::Role::Router';
14 #TODO re-weaken router references when object::remote
15 #weak reference operation is figured out
17 has child_routers => ( is => 'ro', required => 1, default => sub { [] } );
18 has parent_router => ( is => 'rw', );#weak_ref => 1 );
24 # my $parent = $self->parent_router;
25 # return unless defined $parent ;
26 # $parent->add_child_router($self);
30 my ($self, $depth) = @_;
31 $depth = -1 unless defined $depth;
33 my $buf = "\t" x $depth . $self->description . "\n";
34 foreach my $child (@{$self->child_routers}) {
35 next unless defined $child;
36 $buf .= $child->describe($depth);
42 sub add_child_router {
43 my ($self, $router) = @_;
44 push(@{ $self->child_routers }, $router);
45 #TODO re-weaken when object::remote proxied
46 #weak references is figured out
47 # weaken(${ $self->child_routers }[-1]);
51 #sub remove_child_router {
52 # my ($self, $description) = @_;
53 # return delete $self->child_routers->{$description};
56 after handle_log_message => sub {
57 my ($self, @args) = @_;
58 my $parent = $self->parent_router;
60 return unless defined $parent;
61 $parent->handle_log_message(@args);