[wordpress插件] Bang System Logging爆炸系统记录

wordpress 插件 文章 2020-02-29 02:00 504 0 全屏看文

AI助手支持GPT4.0

评分
0
描述

Enable system logging for WordPress plugin and theme development.

为WordPress插件和主题开发启用系统日志记录。

This can make it easier to know what your code is doing.

这样可以更轻松地知道您的代码在做什么。

Features include:

功能包括:

    • Log to the system log or to a file
    • 登录到系统日志或文件

    • Easily append or embed any value in log messages
    • 轻松在日志消息中附加或嵌入任何值

    • Coloured logs indicating strings, numbers, arrays, objects, null values etc.
    • 表示字符串,数字,数组,对象,空值等的彩色日志。

    • Extract values from arrays of objects
    • 从对象数组中提取值

    • Optionally exclude AJAX, Javascripts, CSS and any other pattern of URLs.
    • (可选)排除AJAX,JavaScript,CSS和其他任何形式的URL。

    • Intercept PHP errors and log strict warnings
    • 拦截PHP错误并记录严格警告

    • Measure memory usage between two points, or the time taken by various parts of your code
    • 测量两点之间的内存使用情况,或代码各部分所花费的时间

    • Easy to switch off for production sites
    • 易于关闭生产站点

    How to use

    使用方法

    Using it is as simple as calling the 'log' action in your templates or plugin.

    使用它就像在模板或插件中调用'log'操作一样简单。

      <?php do_action('log','Some log message'); 

    ?>

    ?>

    This will produce a line in your system log:

    这将在系统日志中产生一行:

    Jun  4 11:23:08 myserver php/mysite.com[1553]: b8e mysite.com/path-to-page: Some log message

      6月4日11:23:08 myserver php / mysite.com [1553]:b8e mysite.com/路径到页面:一些日志消息

    This includes:

    这包括:

      • Jun 4 11:23:08 – The date and time of the log message
      • 6月4日11:23:08 –日志消息的日期和时间

      • myserver – The name of this computer
      • myserver –此计算机的名称

      • php – The program that produced the message
      • php –产生消息的程序

      • mysite.com – The domain name of the site
      • mysite.com –网站的域名

      • 1553 – The process ID of the running PHP process
      • 1553 –正在运行的PHP进程的进程ID

      • b8e – A random 3-digit code identifying each page request
      • b8e –标识每个页面请求的3位随机代码

      • mysite.com/path-to-page – The URL of the request
      • mysite.com/path-to-page –请求的URL

      • Some log message – Your message
      • 一些日志消息 –您的消息

      For more detailed instructions, see the How to use tab.

      有关详细说明,请参见使用方法标签。

      How to use

      使用方法

      To log a message, use the 'log' action in your templates or plugins:

      要记录消息,请在模板或插件中使用'log'操作:

        <?php do_action('log','Some log message'); 

      ?>

      ?>

      This will output the log message:

      这将输出日志消息:

      Some log message

       一些日志消息

      Embedding values

      嵌入值

      If you include extra parameters, they’ll be added at the end of the log message:

      如果您包含其他参数,则将它们添加到日志消息的末尾:

        <?php do_action('log','A number and a string',17,'foo'); 

      ?>

      ?>

      This will produce the log message:

      这将产生日志消息:

      A number and a string: 17, foo

       数字和字符串:17,foo

      The value will be formatted correctly depending on its type: integers, strings, arrays, objects, booleans etc.

      该值将根据其类型正确格式化:整数,字符串,数组,对象,布尔值等。

      You don’t need to check if values are null or empty, they’ll still be output safely.

      您无需检查值是否为null或为空,它们仍将安全输出。

      If you put the code %s into your log message, then one of the arguments will be dropped into the message:

      如果将代码%s 放入日志消息中,则其中一个参数将被放入消息中:

        <?php do_action('log','我有%s个数字',count($ numbers),$ numbers); 

      ?>

      ?>

      This will produce the log message:

      这将产生日志消息:

      I have 4 numbers: [9, 16, 307, 1]

       我有4个数字:[9、16、307、1]

      Selecting fields

      选择字段

      Logging a complete object – such as a WordPress post – can be very large, and sometimes it’s only one or two fields you need.

      记录一个完整的对象(例如WordPress帖子)可能非常大,有时只需要一两个字段。

      If you put a string starting with an exclamation point "!" followed by a list of field names, they will be selected from the following object.

      如果您输入的字符串以感叹号“!” 开头,后跟字段名称列表,则将从以下对象中选择它们。

      The following will only show the ID and post_title fields of the post:

      以下内容仅显示帖子的 ID post_title 字段:

        <?php do_action('log','Loaded the post','!ID,post_title',$ post); 

      ?>

      ?>

      This will produce the log message:

      这将产生日志消息:

      Loaded the post: {ID: 1932, post_title: Test page}

       已加载该帖子:{ID:1932,post_title:测试页}

      If you do this with an array of objects, those fields will be selected from each of them.

      如果使用对象数组执行此操作,将从每个字段中选择这些字段。

      The following will output a list of post IDs:

      以下将输出帖子 ID 的列表:

        <?php do_action('log','Loaded%s posts',count($ posts),'!ID',$ posts); 

      ?>

      ?>

      This will produce the log message:

      这将产生日志消息:

      Loaded 3 posts: [1932, 1594, 1103]

       已加载3个帖子:[1932、1594、1103]

      Coloured logs

      彩色日志

      If you have coloured logging switched on, values will appear in different colours to indicate their type.

      如果已打开彩色日志记录,则值将以不同的颜色显示以指示其类型。

      This can make for quicker scanning of log files.

      这样可以更快地扫描日志文件。

      To enable coloured logs, tick the Coloured logs checkbox on the settings page.

      要启用彩色日志,请在设置页面上选中彩色日志复选框。

      Then use the log.sh script, included with this plugin, to decode and display the coloured log files.

      然后,使用此插件随附的 log.sh 脚本解码并显示彩色的日志文件。

安装步骤

Basic installation

基本安装

    1. Upload the bang-syslog directory into the /wp-content/plugins/ directory
    2. bang-syslog 目录上传到 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

    5. Place

    6. 放置 <?php do_action('log','Some log message');

      ?> in your templates and plugins

    7. ?> 在您的模板和插件中

    Early logging for plugin developers

    插件开发者的早期日志记录

    Normally, this plugin can only begin logging once the plugin has loaded.

    通常,该插件只有在加载后才能开始记录。

    If you’re using logging to develop your own plugin, you may find it helpful to activate this plugin earlier.

    如果您使用日志记录来开发自己的插件,则可能会发现早点激活该插件很有帮助。

    Put this line near the bottom of your wp-config.php file:

    将此行放在 wp-config.php 文件底部附近:

    require_once(ABSPATH . 'wp-content/plugins/bang-syslog/include.php');

      require_once(ABSPATH。'wp-content / plugins / bang-syslog / include.php');

    Using the plugin

    使用插件

    The plugin does nothing until it’s called in PHP code.

    在PHP代码中调用该插件之前,该插件不会执行任何操作。

    See the How to use tab for more information.

    有关更多信息,请参见使用方法标签。

下载地址
https://downloads.wordpress.org/plugin/bang-syslog.zip
-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
[wordpress插件] Connector for WooToApp Mobile &#8211; WooCommerce Native Mobile App.WooToApp Mobile的连接器– WooCommerce本机移动应用程序。
[wordpress插件] Catch Web Tools赶上网络工具
[wordpress插件] AForms &#8212; Form Builder for Price Calculator &amp; Cost EstimationAForms —用于价格计算器和成本估算的表单生成器
[wordpress插件] AppBanners应用横幅
[wordpress插件] ClickQuote点击报价
随便看看
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8007
问题? 7240
如何快速搭建抽奖助手小程序(无需代码知识) 5026
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 5979
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5502
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5198
如何解决渲染层网络错误Failed to load media? 16552
小程序找号找回 释放昵称? 2416
我的小程序广告主收入5301,实际进账4406,是怎么回事呀? 2499
删除部分微信用户个人数据的通知,怎么删除? 5538