1 package Object::Remote::Logging;
4 use Scalar::Util qw(blessed);
5 use Object::Remote::Logging::Logger;
7 extends 'Log::Contextual';
10 our $Router_Instance ||= do {
11 require Object::Remote::Logging::Router;
12 Object::Remote::Logging::Router->new;
17 return [qw( trace debug verbose info warn error )];
20 #this is invoked on all nodes
22 my $level = $ENV{OBJECT_REMOTE_LOG_LEVEL};
23 return unless defined $level;
24 my $logger = Object::Remote::Logging::Logger->new(
25 min_level => lc($level),
26 level_names => Object::Remote::Logging::arg_levels(),
29 #TODO check on speed of string compare against a hash with a single key
30 router()->connect(sub {
31 return unless $_[1]->{controller} eq __PACKAGE__;
32 #skip things from remote hosts because they log to STDERR
33 #when OBJECT_REMOTE_LOG_LEVEL is in effect
34 return if $_[1]->{remote}->{connection_id};
39 #this is invoked by the controlling node
41 sub init_logging_forwarding {
42 my ($self, %controller_info) = @_;
44 router()->_remote_metadata({ connection_id => $controller_info{connection_id} });
45 router()->_forward_destination($controller_info{router});