Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log format not recognised - PhpStorm - Ideolog

Tags:

regex

phpstorm

I am using MAMP + PhpStorm + Wordpress. Ideolog says my log format is not recognized. Help me configure it, please.

My log format :

[06-Feb-2020 15:42:09 UTC] PHP Warning:  mysqli_real_connect(): (HY000/2002): No such file or directory in /Volumes/Workspace/Mamp/wordpress/wp-includes/wp-db.php on line 1633
[06-Feb-2020 15:42:09 UTC] PHP Stack trace:
[06-Feb-2020 15:42:09 UTC] PHP   1. {main}() /Volumes/Workspace/Mamp/wordpress/wp-admin/admin-ajax.php:0
[06-Feb-2020 15:42:09 UTC] PHP   2. require_once() /Volumes/Workspace/Mamp/wordpress/wp-admin/admin-ajax.php:22
[06-Feb-2020 15:42:09 UTC] PHP   3. require_once() /Volumes/Workspace/Mamp/wordpress/wp-load.php:37
[06-Feb-2020 15:42:09 UTC] PHP   4. require_once() /Volumes/Workspace/Mamp/wordpress/wp-config.php:92
[06-Feb-2020 15:42:09 UTC] PHP   5. require_wp_db() /Volumes/Workspace/Mamp/wordpress/wp-settings.php:116
[06-Feb-2020 15:42:09 UTC] PHP   6. wpdb->__construct() /Volumes/Workspace/Mamp/wordpress/wp-includes/load.php:425
[06-Feb-2020 15:42:09 UTC] PHP   7. wpdb->db_connect() /Volumes/Workspace/Mamp/wordpress/wp-includes/wp-db.php:632
[06-Feb-2020 15:42:09 UTC] PHP   8. mysqli_real_connect() /Volumes/Workspace/Mamp/wordpress/wp-includes/wp-db.php:1633
[06-Feb-2020 16:37:19 UTC] PHP Warning:  An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/forums/">support forums</a>. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.) in /Volumes/Workspace/Mamp/wordpress/wp-includes/update.php on line 388
[06-Feb-2020 16:37:19 UTC] PHP Stack trace:
[06-Feb-2020 16:37:19 UTC] PHP   1. {main}() /Volumes/Workspace/Mamp/wordpress/wp-admin/plugins.php:0
[06-Feb-2020 16:37:19 UTC] PHP   2. require_once() /Volumes/Workspace/Mamp/wordpress/wp-admin/plugins.php:10
[06-Feb-2020 16:37:19 UTC] PHP   3. do_action() /Volumes/Workspace/Mamp/wordpress/wp-admin/admin.php:367
[06-Feb-2020 16:37:19 UTC] PHP   4. WP_Hook->do_action() /Volumes/Workspace/Mamp/wordpress/wp-includes/plugin.php:478
[06-Feb-2020 16:37:19 UTC] PHP   5. WP_Hook->apply_filters() /Volumes/Workspace/Mamp/wordpress/wp-includes/class-wp-hook.php:312
[06-Feb-2020 16:37:19 UTC] PHP   6. wp_update_plugins() /Volumes/Workspace/Mamp/wordpress/wp-includes/class-wp-hook.php:288
[06-Feb-2020 16:37:19 UTC] PHP   7. trigger_error() /Volumes/Workspace/Mamp/wordpress/wp-includes/update.php:388

Ideolog settings. I think I need to enter some regular expressions.

enter image description here

like image 538
SkyRar Avatar asked Aug 08 '26 16:08

SkyRar


2 Answers

Here is what I have. It's not perfect, but it works.

Log Format:

  • Message pattern: ^\[([^]]+)\s*America/Denver\]\s+([\w\s]+)[.:]\s+(.+)$ (Change "America/Denver" to your timezone, or replace with a more generic regex)
  • Message start pattern: ^\[
  • Time format: dd-MMM-yyyy HH:mm:ss
  • Time capture group: 1
  • Severity capture group: 2
  • Category capture group: 0
  • Apply message pattern to all message lines: unchecked

Patterns: (You can use your own highlighting scheme)

  • ^\s*(?:PHP\s*)?e(rror)?\s*$
  • ^\s*(?:PHP\s*)?w(arn(ing)?)?\s*$
  • ^\s*(?:PHP\s*)?i(nfo)?\s*$
  • ^\s*(?:PHP\s*)?n(otice)?\s*$
  • ^\s*(?:PHP\s*)?f(?:atal(?:\s*error)?)?\s*$

It still doesn't collapse the stack traces, and Ideolog seems to make the file read only within PhpStorm, so deleting log contents is cumbersome.

like image 194
Benjam Avatar answered Aug 11 '26 06:08

Benjam


Yes, you would need to dive into Ideolog configuration on your own: there's no out-of-the box solution for PHP/WP error log it seems, see https://github.com/JetBrains/ideolog/issues/49. You might want to start from https://github.com/JetBrains/ideolog/issues/42.

like image 41
Dmitrii Avatar answered Aug 11 '26 05:08

Dmitrii



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!