Download the PHP package underpin/logger-loader without Composer

On this page you can find all versions of the php package underpin/logger-loader. 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 logger-loader

Underpin Logger Loader

Loader That assists with adding loggers to a WordPress website.

Installation

Using Composer

composer require underpin/loaders/logger

Manually

This plugin uses a built-in autoloader, so as long as it is required before Underpin, it should work as-expected.

require_once(__DIR__ . '/underpin-logger/logger.php');

Setup

  1. Install Underpin. See Underpin Docs
  2. Register new event types as-needed.

Debug Logger

If you're logged in and add underpin_debug=1 to the end of any URL, an "Underpin events" button appears in the admin bar. This provides a debugging interface that dumps out all of the items that were registered in the request, as well as any events that were logged in that request. This context can be useful, especially in production environments where debugging can be difficult.

Event Logging Utility

This plugin includes a utility that makes it possible to log events in this plugin. These logs are written to files in the wp_uploads directory, and comes equipped with a cron job that automatically purges old logs. Additinally, the method in which the logger saves data can be extended by creating a custom Writer class.

Using the Error Logger

This plugin comes with 3 event types - error, warning, and notice. error events get written to a log, and warning or notice only display in the on-screen console when WP_DEBUG is enabled. This allows you to add a ton of notices and warnings without bogging down the system with a lot of file writing.

To write to the logger, simply chain into the logger method.

You can also log WP_Error objects directly.

Caught exceptions can be captured, too.

By default, the logger will return a Log_Item class, but you can also return a WP_Error object, instead with log_as_error

NOTE: It is considered a bad practice to make your error message contain dynamic data. This can mess with logger utilities that use logged events and cause un-necessary bloat for logging utilities that check for identical events that have happened in the past. Instead, put related data in the data array in the 4th argument.

Bad:

Good:

Gather Errors

Sometimes, you will run several functions in a row that could potentially return an error. Gather errors will lump them into a single WP_Error object, if they are actually errors.

Event Types

You can register your own custom event types if you want to log things that do not fit in any of the three defaults. A common example is when a background process runs - it would be nice to have a log of when that runs, and what happened.

To do this, you would need to create a custom event type. That is done by extending the Event_Type class.

Then, you need to add this item to your logger registry. This is usually done in the setup method inside Service_Locator

That's it! Now you can use the background process event type anywhere you want.

Writers

The Event_Type uses a class, called a Writer to write error logs to a file. Underpin comes bundled with a file writing system that works for most situations, but if for some reason you wanted your logger to write events in a different manner, a good way to-do that is by overriding the $writer_class variable of your event type.

Let's say we wanted to receive an email every time our background process logged an event. Writers can help us do that. First, we specify the namespace and class name of the writer that we're going to create.

Then, we create the class in the correct directory that matches our namespace. It should extend the Writer class.

Example

A very basic example could look something like this.

Alternatively, you can extend Event_Type and reference the extended class directly, like so:


All versions of logger-loader with dependencies

PHP Build Version
Package Version
Requires underpin/underpin Version ^2.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 underpin/logger-loader contains the following files

Loading the files please wait ....