Manual:Logging to Special:Log

Note: This is the pre 1.19 way of doing logs. In 1.19 there is a new way that will be documented here soon.

An example of adding a new log type called "foo" for your extension, using the LogPage class. In the MyExtension.php file, add:

// Internal name of the log, Special:Log/foo $wgLogTypes[] = 'foo'; // System message containing the friendly name of the log. Shows up // in the page title and the Special:Log dropdown $wgLogNames['foo'] = 'foo-name'; // System message containing the introductory text on Special:Log when this page is shown $wgLogHeaders['foo'] = 'foo-header';

Create system messages for your extension in MyExtension.i18n.php:

$messages['en'] = array( ...                                                       'foo' => 'Foo',  'foo-name' => 'Foo log',  'foo-header' => 'These events track when Foo events happen in the system.',  'foo-message' => 'A Foo event happened to article $1',  ... );

In the body file MyExtension_body.php, add this code, which adds entries in both Special:Log/foo and Special:RecentChanges:

global $wgTitle, $wgUser; $log = new LogPage('foo');   // See alternative below $log->addEntry('foo',              $wgTitle,               wfMsg('foo-message', $wgTitle->getFullText),              array,               $wgUser);

If you don't want your events to show up in Special:RecentChanges, which might cause watchlist notifications, change the constructor to:

$log = new LogPage('foo', false); // Second arg = false