8000 WP-CLI does not log errors to the path set in WP_DEBUG_LOG · Issue #5601 · wp-cli/wp-cli · GitHub
[go: up one dir, main page]

Skip to content

WP-CLI does not log errors to the path set in WP_DEBUG_LOG #5601

@Dekadinious

Description

@Dekadinious

Bug Report

Describe the current, buggy behavior

I have this set in my wp-config.php file:

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', '/tmp/debug_staging.log');

I have experienced that when I do error_log() through WP-CLI, the log goes to the standard log path of /wp-content/debug.log. This does not happen when errors are triggered by visiting pages and running functions from the browser.

Describe how other contributors can replicate this bug

  1. Register the following command for use through WP-CLI:
public function check_debug()
{
    error_log(WP_DEBUG_LOG);
}
  1. Define WP_DEBUG as true and set a specific path for WP_DEBUG_LOG in wp-config.php

  2. Run check_debug() through WP-CLI

You will see your path from WP_DEBUG_LOG be logged in /wp-content/debug.log

Describe what you expect as the correct outcome

I expect the path of WP_DEBUG_LOG to be logged in the path set in WP_DEBUG_LOG.

Let us know what environment you are running this on

OS:     Linux 5.4.72 #3 SMP Sun Oct 25 11:14:45 UTC 2020 x86_64
Shell:  /bin/sh
PHP binary:     /usr/app/php/7.4.22/bin/php
PHP version:    7.4.22
php.ini used:   /etc/app/php/php.ini
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       [REDACTED]
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0

Provide additional context

I have looked through the code here:

function wp_debug_mode() {

If I paste the function wp_debug_mode() into check_debug() and then error_log $log_path on line 64, I get '/tmp/debug_staging.log' in the log file on the default location. I get nothing in /tmp/debug_staging.log.

I, therefore, do not know where this goes wrong and I have no idea how to fix it.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0