aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-08-16 21:17:49 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-08-16 21:17:49 +0000
commit24fcf2b97d86debeb27ab4ab46a6bc0a2f23f2b2 (patch)
treeed77a895404910f8a2686e4cb65a585ea23f3daf /IkiWiki.pm
parent3357e704539f447eca041430991b079753e2b125 (diff)
downloadikiwiki-24fcf2b97d86debeb27ab4ab46a6bc0a2f23f2b2.tar
ikiwiki-24fcf2b97d86debeb27ab4ab46a6bc0a2f23f2b2.tar.gz
* Add --syslog config option, to log to the syslog.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm24
1 files changed, 22 insertions, 2 deletions
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", "<p>Error: @_</p>");
}
- 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 {