Wordpress活动日志插件

v1.1.5 2021-02-21 23:38 UTC

This package is auto-updated.

Last update: 2024-09-22 07:26:23 UTC


README

Adeptus Banner

简介

Adeptus 是一款轻量级的插件,允许您将 WordPress 网站日志发送到 syslog、logstash、debug.log 和 error_log,以便您无缝地收集、存储、处理和监控日志。

使用 Adeptus,您有以下能力

  • 实时监控所有网站和CMS活动
  • 审核存储的日志信息以用于安全和调试目的
  • 在第三方应用程序(Grafana、Kibana 等)中可视化日志数据
  • 在第三方应用程序中快速生成报告

内置事件

附件

Created
Updated
Deleted/Trashed

核心

Wordpress updated

菜单

Created
Deleted
Menu item added/update/moved/deleted

选项

Option changes

插件

Installed (covered by plugin activation)
Activated/Deactivated
Updated
Deleted (covered by plugin deactivation)

主题

Activated/Deactivated 
Updated

文章(包括所有自定义文章类型)

Created
Updated
Deleted/Trashed
Published

分类法

Category created
Category moved
Category updated
Category deleted

用户

Login
Logout
Profile updated
Password changed
Password reset
Role updated
Created
Deleted/Trashed

致命PHP错误/异常

Ability to disable logging per request (e.g. during imports)

评论

Created
Change Status (Spam/Deleted/Trashed)

小工具(选项)

Added
Updated
Removed

WooCommerce

Woocommerce Options
Add / Edit / Delete Product
Update Product Variation
Ppdate Product Attribute

其他选项

ACF options page(s) (i.e. global content)
Yoast (settings changes)

自定义事件

有时我们需要运行一些自定义事件(例如运行cron作业或导入一些数据),这些事件包含成千上万个事件或数据库更新。为了防止在服务器上存储过多的日志,最好忽略由自定义脚本引起的事件。

在自定义事件中启用/禁用日志记录

要禁用和启用自定义事件(如导入脚本)中的日志记录,请将您不希望记录的脚本包裹在以下函数调用之间

\Adeptus::disableLogging();

// your code here...

\Adeptus::enableLogging();

在这种情况下,这两行之间的事件将不会记录。

示例

function do_import() 
{
    \Adeptus::logEvent([
        'alert_code'        => 20080,
        'alert_level'       => \Psr\Log\LogLevel::INFO,
        'alert_title'       => 'Import Started',
        'alert_description' => 'Import Started',
        'sensor'            => 'ImportExample'
    ]);

    \Adeptus::disableLogging();

    // Perform import
    update_option('blogname',rand());

    \Adeptus::enableLogging();

    \Adeptus::logEvent([
        'alert_code'        => 20080,
        'alert_level'       => \Psr\Log\LogLevel::INFO,
        'alert_title'       => 'Import Finished',
        'alert_description' => 'Imported 100 items successfully',
        'sensor'            => 'ImportExample'
    ]);
}

钩子

adeptus/activate [动作]

Trigger when plugin activates.

adeptus/loggers [动作]

Allows registration of custom loggers.
class MyLogger implements \Psr\Log\LoggerInterface {
    //...
}

add_action('adeptus/loggers', function($alert_manager) {
    $logger = new MyLogger();
    $alert_manager->setLogger($logger);
});

adeptus/sensors [过滤器]

Allows filtering of sensors and/or registration of additional sensors which provide loggable events.

adeptus/alert_manager/alert_title [过滤器]

Allows filtering of the alert title.

adeptus/alert_manager/alert_level [过滤器]

Allows filtering of the alert level.

adeptus/alert_manager/context [过滤器]

Allows filtering of the alert context.

adeptus/alert_manager/loggers [过滤器]

Allows filtering of the loggers when an event is triggered.

adeptus/sensors/options/whitelist [过滤器]

This filter is in OptionsSensor and includes a list of most important options to log.

adeptus/sensors/options/woocommerce_blacklist [过滤器]

Blacklisted WooCommerce options to be ignored.

全局启用/禁用日志记录

要在整个网站上启用日志记录,请将以下行添加到 .env 文件中

define('WP_ADEPTUS_LOGGING_DISABLED', true);