98 lines
2.6 KiB
Diff
98 lines
2.6 KiB
Diff
diff -uNr Log-Log4perl-Appender-Graylog-1.7.orig/lib/Data/DTO/GELF.pm Log-Log4perl-Appender-Graylog-1.7/lib/Data/DTO/GELF.pm
|
|
--- Log-Log4perl-Appender-Graylog-1.7.orig/lib/Data/DTO/GELF.pm 2018-03-28 14:15:13.708000000 +0200
|
|
+++ Log-Log4perl-Appender-Graylog-1.7/lib/Data/DTO/GELF.pm 2018-03-28 14:57:01.000000000 +0200
|
|
@@ -13,6 +13,7 @@
|
|
use Sys::Hostname;
|
|
use Data::UUID;
|
|
use POSIX qw(strftime);
|
|
+use Time::HiRes;
|
|
|
|
use Log::Log4perl;
|
|
|
|
@@ -47,7 +48,8 @@
|
|
|
|
has 'timestamp' => (
|
|
is => 'ro',
|
|
- isa => 'Int',
|
|
+ #isa => 'Int',
|
|
+ isa => 'Num',
|
|
builder => '_build_timestamp',
|
|
);
|
|
|
|
@@ -61,12 +63,27 @@
|
|
isa => 'Str',
|
|
);
|
|
|
|
-has '_line' => (
|
|
+has '_SourceLineNumber' => (
|
|
is => 'rw',
|
|
isa => 'Int',
|
|
);
|
|
|
|
-has '_file' => (
|
|
+has '_SourceFileName' => (
|
|
+ is => 'rw',
|
|
+ isa => 'Str',
|
|
+);
|
|
+
|
|
+has '_SourceClassName' => (
|
|
+ is => 'rw',
|
|
+ isa => 'Str',
|
|
+);
|
|
+
|
|
+has '_SourceMethodName' => (
|
|
+ is => 'rw',
|
|
+ isa => 'Str',
|
|
+);
|
|
+
|
|
+has '_Severity' => (
|
|
is => 'rw',
|
|
isa => 'Str',
|
|
);
|
|
@@ -83,13 +100,20 @@
|
|
}
|
|
|
|
my $trace = Devel::StackTrace->new;
|
|
+ my $subroutine_next = '';
|
|
+ my $found = 0;
|
|
foreach my $frame ( $trace->frames ) {
|
|
+
|
|
+ $subroutine_next ||= $frame->{subroutine} if ($found and $frame->{subroutine} ne "Log::Log4perl::Logger::__ANON__");
|
|
+
|
|
if ( $frame->{subroutine} eq "Log::Log4perl::Logger::__ANON__" ) {
|
|
- $self->_line( $frame->{line} );
|
|
- $self->_file( $frame->{filename} );
|
|
- $self->_facility( $frame->{package} );
|
|
+ $self->_SourceLineNumber( $frame->{line} );
|
|
+ $self->_SourceFileName( $frame->{filename} );
|
|
+ $self->_SourceClassName( $frame->{package} );
|
|
+ $found++;
|
|
}
|
|
}
|
|
+ $self->_SourceMethodName( $subroutine_next );
|
|
|
|
}
|
|
|
|
@@ -105,7 +129,7 @@
|
|
|
|
sub _build_timestamp {
|
|
my $self = shift;
|
|
- return time();
|
|
+ return Time::HiRes::time();
|
|
}
|
|
|
|
sub message {
|
|
diff -uNr Log-Log4perl-Appender-Graylog-1.7.orig/lib/Log/Log4perl/Appender/Graylog.pm Log-Log4perl-Appender-Graylog-1.7/lib/Log/Log4perl/Appender/Graylog.pm
|
|
--- Log-Log4perl-Appender-Graylog-1.7.orig/lib/Log/Log4perl/Appender/Graylog.pm 2018-03-28 14:15:13.708000000 +0200
|
|
+++ Log-Log4perl-Appender-Graylog-1.7/lib/Log/Log4perl/Appender/Graylog.pm 2018-03-28 14:57:01.000000000 +0200
|
|
@@ -70,7 +70,8 @@
|
|
'_name' => $params{name},
|
|
'_category' => $params{log4p_category},
|
|
"_pid" => $$,
|
|
-
|
|
+ "_facility" => $self->{facility} || '',
|
|
+ "_Severity" => $params{log4p_level},
|
|
);
|
|
|
|
my $msg = validate_message( $packet->TO_HASH() );
|