LogFilterPlugin.php

Summary
LogFilterPlugin.php
LogFilterPluginPlugin that allows log messages to be filtered by severity.
LogFilterPluginMain plugin class for LogFilter
onPluginVersionModify a versions array to provide the plugin version info.
onStartLogHook for the StartLog event in common_log().
filterDo the filtering...

LogFilterPlugin

Plugin that allows log messages to be filtered by severity.

postActiv

the micro-blogging software

Copyright

Copyright © 2016-2017, Maiyannah Bishop

Derived from code copyright various sources

  • GNU Social © 2013-2016, Free Software Foundation, Inc
  • StatusNet © 2008-2012, StatusNet, Inc

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses/.

https://www.gnu.org/licenses/agpl.html

About

This plugin will allow you to filter different severities of log message or that match certain PCRE tests from the log file.

Example to disable all debug messages and those containing ‘About to push’

addPlugin(‘LogFilter’, array( ‘priority’ => array(LOG_DEBUG => false), ‘regex’ => array(‘/About to push/’ => false) ));

PHP version

Tested with 7

File Authors

Web

LogFilterPlugin

Main plugin class for LogFilter

Variables

  • $default - Set to false to require opting things in
  • $priority - override by priority: array(LOG_ERR => true, LOG_DEBUG => false)
  • $regex - override by regex match of message: array(‘/twitter/i’ => false)

TODO: add an admin panel

Summary
onPluginVersionModify a versions array to provide the plugin version info.
onStartLogHook for the StartLog event in common_log().
filterDo the filtering...

onPluginVersion

function onPluginVersion(array &$versions)

Modify a versions array to provide the plugin version info.

Parameters

  • array $versions - versions array to modify

Returns

  • boolean true

onStartLog

function onStartLog(&$priority,
&$msg,
&$filename)

Hook for the StartLog event in common_log().  If a message doesn’t pass our filters, we’ll abort it.

Parameters

  • string $priority - log message priority
  • string $msg - the log message itself
  • string $filename - location of log file

Returns

  • boolean hook result code

filter

function filter($priority,
$msg)

Do the filtering...

Paramters

  • string $priority - log message priority
  • string $msg - the log message itself

Returns

  • boolean true to let the log message be processed
function onPluginVersion(array &$versions)
Modify a versions array to provide the plugin version info.
function onStartLog(&$priority,
&$msg,
&$filename)
Hook for the StartLog event in common_log().
function filter($priority,
$msg)
Do the filtering...