Output a | character in log message continuation lines

This makes it easier to tell where multi-line log messages begin and
end.
This commit is contained in:
Richard Hansen 2024-05-22 19:28:03 -04:00
parent ff39ce3874
commit 9c6e5fdda4
3 changed files with 14 additions and 10 deletions

View file

@ -38,6 +38,9 @@ repository history](https://github.com/ddclient/ddclient/commits/master).
[#639](https://github.com/ddclient/ddclient/pull/639)
* Updated sample systemd service unit file to improve logging in the systemd
journal. [#669](https://github.com/ddclient/ddclient/pull/669)
* The second and subsequent lines in a multi-line log message are now prefixed
with a `|` character.
[#676](https://github.com/ddclient/ddclient/pull/676)
### Bug fixes

View file

@ -2406,6 +2406,7 @@ sub logmsg {
}
if ($prefix) {
$buffer = "$prefix$buffer";
$prefix =~ s/ $/| /;
$buffer =~ s/\n/\n$prefix/g;
}
$buffer .= "\n";

View file

@ -60,7 +60,7 @@ my @test_cases = (
{
desc => 'multi-line prefix',
args => [pfx => 'PFX:', "foo\nbar"],
want => "PFX: foo\nPFX: bar\n",
want => "PFX: foo\nPFX: | bar\n",
},
{
desc => 'single-line long prefix',
@ -70,7 +70,7 @@ my @test_cases = (
{
desc => 'multi-line long prefix',
args => [pfx => 'VERY LONG PREFIX:', "foo\nbar"],
want => "VERY LONG PREFIX: foo\nVERY LONG PREFIX: bar\n",
want => "VERY LONG PREFIX: foo\nVERY LONG PREFIX:| bar\n",
},
{
desc => 'single line, no prefix, file',
@ -97,7 +97,7 @@ my @test_cases = (
args => [pfx => 'PFX:', "foo\nbar"],
file => 'name',
lineno => 42,
want => "PFX: file name, line 42: foo\nPFX: file name, line 42: bar\n",
want => "PFX: file name, line 42: foo\nPFX: file name, line 42:| bar\n",
},
);