package Object::Remote::Connection;
-use Object::Remote::Logging qw (:log :dlog get_router);
+use Object::Remote::Logging qw (:log :dlog router);
use Object::Remote::Future;
use Object::Remote::Null;
use Object::Remote::Handle;
use Moo;
BEGIN {
- get_router()->exclude_forwarding;
+ router()->exclude_forwarding;
#this will reap child processes as soon
#as they are done executing so the process
use warnings;
use base qw(Exporter);
-use Object::Remote::Logging qw( :log get_router );
+use Object::Remote::Logging qw( :log router );
-BEGIN { get_router()->exclude_forwarding }
+BEGIN { router()->exclude_forwarding }
use CPS::Future;
use Object::Remote::Proxy;
use Scalar::Util qw(weaken blessed);
-use Object::Remote::Logging qw ( :log get_router );
+use Object::Remote::Logging qw ( :log router );
use Object::Remote::Future;
#must find way to exclude certain log events
#from being forwarded - log events generated in
use Module::Runtime qw(use_module);
use Moo;
-BEGIN { get_router()->exclude_forwarding }
+BEGIN { router()->exclude_forwarding }
has connection => (
is => 'ro', required => 1,
use Moo;
use Scalar::Util qw(blessed);
use Object::Remote::Logging::Logger;
+use Exporter::Declare;
extends 'Log::Contextual';
+exports(qw( router ));
+
sub router {
our $Router_Instance ||= do {
require Object::Remote::Logging::Router;
sub _log {
my ($self, $level, $content, $metadata_in) = @_;
- #TODO this stinks but is backwards compatible with the original logger api
my %metadata = %$metadata_in;
my $rendered = $self->_render($level, \%metadata, @$content);
$self->_output($rendered);
sub _render {
my ($self, $level, $metadata, @content) = @_;
- my $rendered = "[$level] ";
my $remote_info = $metadata->{object_remote};
+ my $when = $metadata->{timestamp};
+ my $rendered;
+ if (defined($when)) {
+ $when = localtime($when);
+ } else {
+ $when = 'no time data';
+ }
+
if ($remote_info) {
- $rendered .= "[connection #$remote_info->{connection_id}] ";
+ $rendered .= "[$level connection #$remote_info->{connection_id}] [$when] ";
} else {
- $rendered .= "[local] ";
+ $rendered .= "[$level local] [$when] ";
}
+
$rendered .= join('', @content);
- $rendered .= "\n" unless substr($rendered, -1) eq "\n";
+ chomp($rendered);
+ $rendered =~ s/\n/\n /g;
+ $rendered .= "\n";
return $rendered;
}
#to caller level will be available in the future
delete $metadata{caller_level};
$metadata{object_remote} = $self->_remote_metadata;
-
+ $metadata{timestamp} = time;
foreach my $logger ($self->_get_loggers(%metadata)) {
$logger->$level([ $generator->(@args) ], \%metadata);
}
use IO::Select;
use Time::HiRes qw(time);
-use Object::Remote::Logging qw( :log :dlog get_router );
+use Object::Remote::Logging qw( :log :dlog router );
use Moo;
-BEGIN { get_router()->exclude_forwarding }
+BEGIN { router()->exclude_forwarding }
# this is ro because we only actually set it using local in sub run
has is_running => (is => 'ro', clearer => 'stop');
use CPS::Future;
use Scalar::Util qw(weaken openhandle);
-use Object::Remote::Logging qw(:log :dlog get_router );
+use Object::Remote::Logging qw(:log :dlog router );
use Moo;
-BEGIN { get_router()->exclude_forwarding }
+BEGIN { router()->exclude_forwarding }
has fh => (
is => 'ro', required => 1,
use IPC::Open3;
use IO::Handle;
use Symbol;
-use Object::Remote::Logging qw( :log :dlog get_router );
+use Object::Remote::Logging qw( :log :dlog router );
use Object::Remote::ModuleSender;
use Object::Remote::Handle;
use Object::Remote::Future;
my ($conn) = $f->get;
$self->_setup_watchdog_reset($conn);
my $sub = $conn->remote_sub('Object::Remote::Logging::init_logging_forwarding');
- $sub->('Object::Remote::Logging', router => get_router, connection_id => $conn->_id);
+ $sub->('Object::Remote::Logging', router => router(), connection_id => $conn->_id);
Object::Remote::Handle->new(
connection => $conn,
class => 'Object::Remote::ModuleLoader',
package main;
-use Object::Remote::Logging qw( get_router );
+use Object::Remote::Logging qw( router );
#make sure to enable execution of every logging code block
#by setting the log level as high as it can go
-get_router->connect(Object::Remote::Logging::TestOutput->new(
+router->connect(Object::Remote::Logging::TestOutput->new(
min_level => 'trace', max_level => 'error',
level_names => Object::Remote::Logging->arg_levels(),
));