diff --git a/IkiWiki.pm b/IkiWiki.pm index 560647e06..4fc37110b 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -21,6 +21,7 @@ sub defaultconfig () { #{{{ wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]*)\]\]/, wiki_file_regexp => qr/(^[-[:alnum:]_.:\/+]+$)/, verbose => 0, + syslog => 0, wikiname => "wiki", default_pageext => "mdwn", cgi => 0, @@ -119,12 +120,31 @@ sub error ($) { #{{{ print "Content-type: text/html\n\n"; print misctemplate("Error", "
Error: @_
"); } - die @_; + log_message(error => @_); + exit(1); } #}}} sub debug ($) { #{{{ return unless $config{verbose}; - if (! $config{cgi}) { + log_message(debug => @_); +} #}}} + +my $log_open=0; +sub log_message ($$) { #{{{ + my $type=shift; + + if ($config{syslog}) { + require Sys::Syslog; + unless ($log_open) { + Sys::Syslog::setlogsock('unix'); + Sys::Syslog::openlog('ikiwiki', '', 'user'); + $log_open=1; + } + eval { + Sys::Syslog::syslog($type, join(" ", @_)); + } + } + elsif (! $config{cgi}) { print "@_\n"; } else { diff --git a/debian/changelog b/debian/changelog index 2bf2665c7..7ed15dcb1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,8 +3,9 @@ ikiwiki (1.20) UNRELEASED; urgency=low * Relicense the templates and basewiki under the 2-clause BSD license. Since these can easily become part of other people's websites, they should be under as permissive a license as possible. + * Add --syslog config option, to log to the syslog. - -- Joey Hess