]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Add --syslog config option, to log to the syslog.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 16 Aug 2006 21:17:49 +0000 (21:17 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 16 Aug 2006 21:17:49 +0000 (21:17 +0000)
IkiWiki.pm
debian/changelog
doc/ikiwiki.setup
doc/usage.mdwn
ikiwiki.pl

index 560647e067f224bd62d2c9cd49b9c17359933b9f..4fc37110b95940a1340d721b6a6e93e17813f0d1 100644 (file)
@@ -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 {
index 2bf2665c717a86067b6b543d69a1855756af4ed9..7ed15dcb191f08f82ffe902da2ac131ab973a8d5 100644 (file)
@@ -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 <joeyh@debian.org>  Wed, 16 Aug 2006 16:30:44 -0400
+ -- Joey Hess <joeyh@debian.org>  Wed, 16 Aug 2006 17:07:35 -0400
 
 ikiwiki (1.19) unstable; urgency=low
 
index bef858d5b34df9c7072bef7a9d3c2ef0728c4e2a..e149912994010d4beab2f98938bcc84b93b8d78a 100644 (file)
@@ -74,6 +74,9 @@ use IkiWiki::Setup::Standard {
        #timeformat => '%c',
        # Locale to use. Must be a UTF-8 locale.
        #locale => 'en_US.UTF-8',
+       # Logging settings:
+       verbose => 0,
+       syslog => 0,
        
        # To add plugins, list them here.
        #add_plugins => [qw{meta tag pagecount brokenlinks search smiley
index 048072df60d5c2f2c2fcca5e673661c0258b6ff3..e0c7800d5928a091e37f0224cca470bf8f9be6f8 100644 (file)
@@ -212,10 +212,14 @@ configuration options of their own.
   Specify how to display the time or date. The format string is passed to the
   strftime(3) function.
 
-* --verbose
+* --verbose, --no-verbose
 
   Be vebose about what is being done.
 
+* --syslog, --no-syslog
+
+  Log to syslog.
+
 * --w3mmode, --no-w3mmode
 
   Enable [[w3mmode]], which allows w3m to use ikiwiki as a local CGI script,
index fd9300fbabed31f31413ab7efd6fb044e3ea11ad..c9b53a03181f3787aa13106ea2f9bf7033834206 100755 (executable)
@@ -23,6 +23,7 @@ sub getconfig () { #{{{
                        "setup|s=s" => \$config{setup},
                        "wikiname=s" => \$config{wikiname},
                        "verbose|v!" => \$config{verbose},
+                       "syslog!" => \$config{syslog},
                        "rebuild!" => \$config{rebuild},
                        "refresh!" => \$config{refresh},
                        "wrappers!" => \$config{wrappers},