aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm5
-rw-r--r--t/syslog.t12
2 files changed, 12 insertions, 5 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 2c0b1153c..86c850811 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -740,7 +740,10 @@ sub log_message ($$) {
$log_open=1;
}
eval {
- Sys::Syslog::syslog($type, "[$config{wikiname}] %s", join(" ", @_));
+ # keep a copy to avoid editing the original config repeatedly
+ my $wikiname = $config{wikiname};
+ utf8::encode($wikiname);
+ Sys::Syslog::syslog($type, "[$wikiname] %s", join(" ", @_));
};
if ($@) {
print STDERR "failed to syslog: $@" unless $log_failed;
diff --git a/t/syslog.t b/t/syslog.t
index 28272e2dc..ffe8635b3 100644
--- a/t/syslog.t
+++ b/t/syslog.t
@@ -1,14 +1,18 @@
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 3;
+use Test::More tests => 5;
use utf8;
BEGIN { use_ok("IkiWiki"); }
$IkiWiki::config{verbose} = 1;
$IkiWiki::config{syslog} = 1;
-$IkiWiki::config{wikiname} = 'ascii';
-is(debug('test'), '');
+
+$IkiWiki::config{wikiname} = 'ASCII';
+is(debug('test'), '', 'plain ASCII syslog');
$IkiWiki::config{wikiname} = 'not â’¶SCII';
-is(debug('test'), '');
+is(debug('test'), '', 'UTF8 syslog');
+my $orig = $IkiWiki::config{wikiname};
+is(debug('test'), '', 'check for idempotency');
+is($IkiWiki::config{wikiname}, $orig, 'unchanged config');