Skip to content

Improve logging and log visibility #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MichelleBlanchette opened this issue Apr 16, 2023 · 2 comments
Open

Improve logging and log visibility #134

MichelleBlanchette opened this issue Apr 16, 2023 · 2 comments
Labels
cleanup Improves code organization and usability documentation Related to documentation

Comments

@MichelleBlanchette
Copy link
Collaborator

MichelleBlanchette commented Apr 16, 2023

Refer to WordPress's usage in the source code of this function: https://developer.wordpress.org/reference/functions/_deprecated_function/

The trigger_error() function has all the verbosity I've been wanting, such as the file and line number where called.

Applicable constants are here: https://www.php.net/manual/en/errorfunc.constants.php

  • E_USER_ERROR
  • E_USER_WARNING
  • E_USER_NOTICE
  • E_USER_DEPRECATED

Should also probably wrap error logging within checks for if ( WP_DEBUG ) like WordPress core does, as well. 🤷
^ No, because I don't want to require this to help debug something for someone.

@MichelleBlanchette MichelleBlanchette added documentation Related to documentation minor An easy or less important task cleanup Improves code organization and usability labels Apr 16, 2023
@MichelleBlanchette
Copy link
Collaborator Author

Better yet, all logging should be handled custom and visible in an admin screen for the plugin! Logging to the server doesn't help with support requests where I simply gain access to their WordPress admin. (And I definitely don't want SSH access to their server, anyways!)

@MichelleBlanchette MichelleBlanchette changed the title Prefer trigger_error() over error_log() Improve logging and log visibility Nov 10, 2023
@MichelleBlanchette MichelleBlanchette self-assigned this Jan 8, 2024
@MichelleBlanchette MichelleBlanchette removed the minor An easy or less important task label Jan 12, 2024
@MichelleBlanchette MichelleBlanchette removed their assignment Apr 7, 2024
@MichelleBlanchette
Copy link
Collaborator Author

A few thoughts I just randomly had on this:

  • Log file should be in wp-content/uploads folder so it doesn't get deleted every time the plugin files are updated (also, see about WordPress VIP's filesystem restrictions which permit that folder only)
  • Download button should be made available in wp-admin to download the log file so it can be provided to technical support (we should never have a reason to log into a user's system)
  • Log function can probably mimic trigger_error()'s verbosity by getting the prior stacktrace function automatically (we shouldn't need to manually pass __FUNCTION__ every time like wp_trigger_error() expects... 🙄
  • Setting to enable or disable logging, default to disabled since users should only need logging to debug issues (like us in active development)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Improves code organization and usability documentation Related to documentation
Projects
None yet
Development

No branches or pull requests

1 participant