2 /* Syslog.php -- an extension to log events to the system logger
3 * Copyright 2004 Evan Prodromou <evan@wikitravel.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * @author Evan Prodromou <evan@wikitravel.org>
21 * @subpackage Extensions
24 if (defined('MEDIAWIKI')) {
28 if (!isset($wgSyslogIdentity)) {
29 $wgSyslogIdentity = $wgDBname;
31 if (!isset($wgSyslogFacility)) {
32 $wgSyslogFacility = LOG_USER
;
37 function syslogUserLogin(&$user) {
38 syslog(LOG_INFO
, "User '" . $user->getName() . "' logged in.");
44 function syslogUserLogout(&$user) {
45 syslog(LOG_INFO
, "User '" . $user->getName() . "' logged out.");
49 # Setup -- called once environment is configured
51 function setupSyslog() {
53 global $wgSyslogIdentity, $wgSyslogFacility, $_syslogId;
56 openlog($wgSyslogIdentity, LOG_ODELAY | LOG_PID
, $wgSyslogFacility);
58 $wgHooks['UserLoginComplete'][] = syslogUserLogin
;
59 $wgHooks['UserLogout'][] = syslogUserLogout
;
64 # Add to global list of extensions
66 $wgExtensionFunctions[] = setupSyslog
;