wp-search-with-algolia icon indicating copy to clipboard operation
wp-search-with-algolia copied to clipboard

Maybe add an actual logger

Open richaber opened this issue 4 years ago • 3 comments

Multiple places in the code use error_log() when a catchable exception occurs. Consider using an actual logger. Would need an option to enable/disable logging. Log file would need to be written to a directory in uploads that is specific to the plugin. Not sure that we need log level to be configurable. If it were, maybe just two levels, debug (noisy), or error only. Debug would be useful in development. Default to error only. Default to disabled.

richaber avatar Jul 31 '20 20:07 richaber

I've got an experimental branch try/php-scoper that uses PHP-Scoper as part of a build process, so that we can bundle PHP vendor libraries with prefixed namespaces, in anticipation of adding a package like Monolog.

PHP-Scoper would also allow us to isolate the Algolia PHP Client we ship, in case anyone has a different version installed via another plugin, and Algolia's PHP Client now uses Guzzle where available, so we could potentially ship that as well.

richaber avatar Jul 31 '21 01:07 richaber

I've got an experimental branch try/php-scoper that uses PHP-Scoper as part of a build process, so that we can bundle PHP vendor libraries with prefixed namespaces, in anticipation of adding a package like Monolog.

PHP-Scoper would also allow us to isolate the Algolia PHP Client we ship, in case anyone has a different version installed via another plugin, and Algolia's PHP Client now uses Guzzle where available, so we could potentially ship that as well.

It is worth noting that we would need to namespace the whole plugin, necessitating a new MAJOR version. Additionally, as PHP-Scoper is still a 0.x.x release, there are sometimes breaking changes, for example, some of the scoper configuration keys have changed between when I opened that branch and now. Also worth noting that PHP-Scoper is a little finicky, and creates aliases for functions and classes from the global space which has caused some issues in testing.

richaber avatar Aug 31 '21 19:08 richaber

I have an experimental try/strauss branch, that uses brianhenryie/strauss to prefix vendor libs. The approach used with that means we wouldn't need to namespace our whole plugin right now to implement, meaning we could put off another MAJOR version change for a little while longer (which could be disruptive to users, since we recently released 2.0.0).

richaber avatar Nov 20 '21 00:11 richaber