Download the PHP package brianhenryie/bh-wp-logger without Composer

On this page you can find all versions of the php package brianhenryie/bh-wp-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bh-wp-logger

BH WP Logger

Zero-config logger UI for WordPress plugins.

Wraps existing PSR-3 loggers and adds some UI.

Uses KLogger by default, WC_Logger when specified, NullLogger when log level is set to "none".

Uses PHP's set_error_handler() to catch PHP deprecated/warning/notice/errors.

Hook into WordPress's deprecated function hooks (deprecated_function_run etc.) to log those only once per day.

Uses PHP's register_shutdown_function() to catch Exceptions related to the plugin.

Deletes log files older than 30 days on cron.

Records a full backtrace on errors. Records two steps of backtrace on every log when the level is Debug.

UI

Displays logs in WP_List_Table.

Shows a dismissible admin error notice each time there is a new error.

Adds a link to the logs view on the plugin's entry on plugins.php.

When log messages contain `wp_user:123` (NB: surrounded by single backticks) it will be replaced with a link to the user profile. This allows for logging useful references to users without logging their PII.

Similarly, any post type can be linked with `post_type_name:123`, e.g. `shop_order:123` will link to the WooCommerce order.

Use

Composer

Expect breaking changes with every release until v1.0.0.

Instantiate

You should use brianhenryie/strauss to prefix the library's namespace. Then Strauss's autoloader will include the files for you.

The following will work, but it will be faster and more reliable to provide the settings:

Provide the settings:

Then pass around your $logger instance.

After the logger has been instantiated once, subsequent calls to ::instance() return the existing instance and any $logger_settings passed is ignored.

To use WooCommerce's native WC_Logger, use the WooCommerce_Logger_Interface interface (which just extends Logger_Settings_Interface) on the settings object.

WooCommerce Settings

Something like this can be used for WooCommerce Settings API.

Filters

Two filters are present, to modify the log data as it is being saved, and to modify the log data as it is being presented.

E.g. change the log level for specific log messages:

E.g. turn text in logs into hyperlinks as it is being displayed in the logs table:

WP_Mock

If using WP_Mock for your tests, and you are instantiating this logger, the following should help:

Test Plugin

The test-plugin folder contains a small plugin with buttons to trigger the types of errors that can be logged.

Best Practice

From my limited logging experience, I find it useful to add a debug log at the beginning of functions and an appropriate info...error as the function returns.

TODO

Minor concerns:

Status

To date I think it has been used mostly by me, i.e. internal projects. There are no egregious issues. It should work for everyone but I would like some feedback from others on how well it works for you.

I'll start at Semver 1.0.0 once I've caught up with WPCS, PhpStan and PhpUnit. There's about 65 tests and 43% coverage. WPCS + PHPStan are both pretty good.

I think that's higher code-quality than most WordPress plugins.


All versions of bh-wp-logger with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
brianhenryie/bh-wp-private-uploads Version ^0.1.1
brianhenryie/bh-wc-logger Version ^0.1.0
brianhenryie/bh-wp-cli-logger Version ^1.0
katzgrau/klogger Version dev-master
psr/log Version ^1.0
wptrt/admin-notices Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package brianhenryie/bh-wp-logger contains the following files

Loading the files please wait ....