hierarchical log routing is now implemented in object-remote instead of log-contextual
[scpubgit/Object-Remote.git] / lib / Object / Remote / Role / LogForwarder.pm
CommitLineData
f7ea4120 1package Object::Remote::Role::LogForwarder;
2
3use Moo::Role;
4
5with 'Log::Contextual::Role::Router';
6
7#TODO re-weaken router references when object::remote
8#weak reference operation is figured out
9
10has child_routers => ( is => 'ro', required => 1, default => sub { {} } );
11has parent_router => ( is => 'rw', );#weak_ref => 1 );
12
13#adds a child router to this router and gives it
14#a friendly display name
15sub add_child_router {
16 my ($self, $description, $router) = @_;
17 $self->child_routers->{$description} = $router;
18 #weaken($self->child_routers->{$class});
19 $router->parent_router($self);
20 return;
21}
22
23sub remove_child_router {
24 my ($self, $description) = @_;
25 return delete $self->child_routers->{$description};
26}
27
28after handle_log_message => sub {
29 my ($self, @args) = @_;
30 my $parent = $self->parent_router;
31
32 return unless defined $parent;
33 $parent->handle_log_message(@args);
34};
35
361;