From 7fe03ce1a544d336e9789dc7b00105743c7b2507 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 27 Mar 2019 23:24:56 +0100 Subject: [PATCH] Allow overriding short_message --- systemd-journal-gelf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/systemd-journal-gelf b/systemd-journal-gelf index bc68ce7..b8539eb 100644 --- a/systemd-journal-gelf +++ b/systemd-journal-gelf @@ -168,12 +168,14 @@ while ( my $entry = ){ # OR # # gelf(~):code=200~url=/index.html~remote_ip=10.99.5.12~referer=http://test.local/ - if ( $msg->{MESSAGE} =~ m/^gelf(\([^\(\)]+\))?:([a-zA-Z\d_\-]+=([^\|])\|?)+/ ){ + if ( $msg->{MESSAGE} =~ m/^gelf(\([^\(\)]+\))?:([a-zA-Z\d_\-]+=([^\|]+)\|?)+/ ){ $msg->{MESSAGE} =~ s/^gelf(\([^\(\)]+\))?://; my $separator = ($1 && length $1 > 0) ? qr{$1} : qr{\|}; foreach ( split /$separator/, $msg->{MESSAGE} ){ - my ( $key, $val ) = split /=/, $_; - $gelf->{'_' . lc $key} = $val; + my ( $key, $val ) = split /=/, $_, 2; + # Allow overriding short message + $key = '_' . $key unless ($key eq 'short_message'); + $gelf->{$key} = $val; } }