Skip to content

Conversation

@salcode
Copy link
Owner

@salcode salcode commented Feb 18, 2018

This PR modifies logging to the error log when WP CLI is being used.

On the first pass, we're suppressing the email logging because when we write to the error log when using WP CLI it shows up in our on page output.

I'm not certain if this is the best solution. I think ideally, even when using WP CLI, I'd like to write the stopped email information in the error log (but not output the stopped email on the command line).

Props @mitchelldmiller for bringing up the issue of the current behavior, which definitely needs to be improved.

See #15

Add check when logging outgoing messages to the error log, for WP CLI.
If WP CLI is being used, displaying a single warning rather than dumping
the entire email to the error log. Writing to the error log populates on
the screen when using WP CLI.

See #15
@mitchelldmiller
Copy link

Hello @salcode ,
WP-CLI message needs translation:

WP_CLI::warning( __( 'Stop Emails: Not logging email to error log, because WP CLI is being used.', 'stop-emails' ) );

Best wishes,
Mitchell

@salcode
Copy link
Owner Author

salcode commented Feb 22, 2018

@mitchelldmiller Good point about needing to wrap the string in a translation function - thanks.

@salcode
Copy link
Owner Author

salcode commented Feb 22, 2018

I've been giving this overall topic some more thought. Previously, I said

I think ideally, even when using WP CLI, I'd like to write the stopped email information in the error log (but not output the stopped email on the command line).

I've given this some further thought. I do my development using Local by Flywheel, which uses Docker to run the WordPress sites within a virtual machine. Through some clever configuration that others far smarter than I figured out, I'm able to run WP CLI from my host machine on the guest machine inside docker. More details on using WP CLI from the host machine with Local by Flywheel. In this case, I don't think I know a way to write an email to the site error log on the guest machine, since we're running the PHP files on the host machine using a copy of PHP there.

Therefore, I think we should definitely be providing some sort of message in WP CLI.

It can be as simple as the message we're currently considering

Stop Emails: Not logging email to error log, because WP CLI is being used.

but ultimately, it seems it would be helpful to log the actual email that is stopped (though in a nice format for WP CLI).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants