Force log messages to be bytestrings

Sys::Syslog is not UTF-8-literate.
master
Simon McVittie 2016-01-21 07:25:25 +00:00
parent a8951de19e
commit b8dbb48fdc
2 changed files with 4 additions and 2 deletions

View File

@ -846,7 +846,9 @@ sub log_message ($$) {
# keep a copy to avoid editing the original config repeatedly
my $wikiname = $config{wikiname};
utf8::encode($wikiname);
Sys::Syslog::syslog($type, "[$wikiname] %s", join(" ", @_));
my $message = join(" ", @_);
utf8::encode($message);
Sys::Syslog::syslog($type, "[$wikiname] %s", $message);
};
if ($@) {
print STDERR "failed to syslog: $@" unless $log_failed;

View File

@ -12,7 +12,7 @@ $IkiWiki::config{syslog} = 1;
$IkiWiki::config{wikiname} = 'ASCII';
is(debug('test'), '', 'plain ASCII syslog');
$IkiWiki::config{wikiname} = 'not ⒶSCII';
is(debug('test'), '', 'UTF8 syslog');
is(debug('𝗧ĕṡҭ'), '', 'UTF8 syslog');
my $orig = $IkiWiki::config{wikiname};
is(debug('test'), '', 'check for idempotency');
is($IkiWiki::config{wikiname}, $orig, 'unchanged config');