葉隠 – Yet Another Error Reporter

説明

Have you ever seen an error log like the one below?

PHP Fatal error: Allowed memory size of xxxxxx bytes exhausted (tried to allocate xxx bytes) in /var/www/wordpress/wp-includes/wp-db.php on line 2007

This means that PHP memory limit is exhausted while retrieving data from a database. In any case, this happens when your site has big data and makes insane loops inside.

しかし、私たちが知りたいのは、どのプラグインがデータを取得しているのか?です。

葉隠は wp-db.php がメモリー上限エラーを引き起こすと、追加の情報を error.log ファイルに追加します:

[08-May-2019 10:28:37 UTC] wpdb Error Backtrace:
#1      Kunoichi\Hagakure\DbLogger->filter_query()      /app/public/wp-includes/class-wp-hook.php       Line 286
#2      WP_Hook->apply_filters()        /app/public/wp-includes/plugin.php      Line 208
#3      apply_filters   /app/public/wp-includes/wp-db.php       Line 1871
#4      wpdb->query()   /app/public/wp-includes/wp-db.php       Line 2579
#5      wpdb->get_results()     /app/public/wp-includes/class-wp-query.php      Line 2979
#6      WP_Query->get_posts()   /app/public/wp-includes/class-wp-query.php      Line 3387
#7      WP_Query->query()       /app/public/wp-includes/post.php        Line 1961
#8      get_posts       /app/public/wp-content/plugins/hagakure/hagakure.php    Line 34
#9      {closure}       /app/public/wp-includes/class-wp-hook.php       Line 286
#10     WP_Hook->apply_filters()        /app/public/wp-includes/class-wp-hook.php       Line 310
#11     WP_Hook->do_action()    /app/public/wp-includes/plugin.php      Line 465
#12     do_action       /app/public/wp-includes/template-loader.php     Line 13
#13     require_once    /app/public/wp-blog-header.php  Line 19
#14     require /app/public/index.php   Line 17

This log will always follow the memory limit Fatal Error by wp-db.php. Now you can find #8 calls get_posts repeatedly.

We recommend watching logs with notification services like CloudWatch Logs.
This error occurs in the productional environment, and you may not have a chance to see it occurs.
We use Hagakure with our hosting service, please look forward to seeing our blog published and describing the integration!

This plugin also adds debug backtrace to error logs. To modify the error level to a detailed backtrace, define the constant:

define( 'HAGAKURE_ERROR_LEVEL', E_NOTICE | E_USER_WARNING | E_WARNING | E_USER_ERROR );

Besides that, if SAVEQUERIES is set true, the slow query log will be logged with PHP debug backtrace. This helps you to debug.

Acknowledgements

The base text for dummy content is “Three Ghost Story” by Charles Dickens. The text file is modified the one of Project Gutenberg.

インストール

  1. hagakure フォルダーを /wp-content/plugins ディレクトリーにアップロードしてください。
  2. WordPress の “プラグイン” メニューから有効化してください。
  3. 以上です。このプラグインはバックグラウンドで動作します。

FAQ

どうやったら貢献できますか?

このプラグインは GitHub kuno1/hagakure にホストされています。気軽にプルリクエストを送ったり、イシューを立てたりしてください。

評価

2019年5月10日
This plugin makes it easy to find the root cause of PHP Fatal error: Allowed memory size of xxxxxx bytes exhausted error. AWESOME.
2件のレビューをすべて表示

貢献者と開発者

葉隠 – Yet Another Error Reporter はオープンソースソフトウェアです。以下の人々がこのプラグインに貢献しています。

貢献者

“葉隠 – Yet Another Error Reporter” は1ロケールに翻訳されています。 翻訳者のみなさん、翻訳へのご協力ありがとうございます。

“葉隠 – Yet Another Error Reporter” をあなたの言語に翻訳しましょう。

開発に興味がありますか ?

コードを閲覧するか、SVN リポジトリをチェックするか、開発ログRSS で購読してみてください。

変更履歴

1.2.0

  • Slow query can be logged with the backtraces.

1.1.0

  • Add Request URI to backtrace.

1.0.0

  • Warning と Notice の詳細を扱えるよう変更。

0.8.0

  • First Release.