An actual logger for WordPress.

Overview

Wp-logger

An actual logger for WordPress.

This plugin does two things. It piggybacks on the internal php logger (via set_error_handler) and it creates a PSR logger for you to use!

More in-depth

When the plugin have loaded completely in WordPress, it will fire the jitesoft_logger_loaded action, the callback will be passed the global logger object.
If you know that the plugin is loaded, you can as well use the jitesoft('logger') function to request the logger instance. In case it is not yet loaded, the function will return null:

$logger = jitesoft('logger'); // null if not lodaed
add_action('jitesoft_logger_loaded', static fn($logger) => $logger); // will not be null when loaded.

Deprecation notice, the following will be removed in next major version

It's also possible to fetch the logger through the GlobalLogger class through the logger() method:

Jitesoft\WordPress\Plugins\Logger\GlobalLogger;

$logger = GlobalLogger::logger();

Auto-loading

The plugin requires auto-loading to function properly. Without the autoloader, the plugin won't be able to find the libraries it uses and hence will not create a logger.

Configuring

The plugin is currently configured via environment variables or defines. The values must be defined before loading the plugin, so the wp-config.php file or actual environment variables are preferable places to put those.

WP_LOGGER_OVERRIDE is default set to override, can be changed to disable to not override the internal php logger.

WP_ENV sets the default logging level on the logger:

  • production: errors and above
  • staging: info and above
  • development: debug and above

In case you wish to change the logging level manually, you can set the WP_LOGGER_LEVEL to an appropriate level, the following are accepted: debug, notice, info, warning, error, critical, alert, emergency.

You can also change the log level by fireing the jitesoft_log_level hook with a single string parameter with a value of the above log levels.

Formatting

Currently, the logger supports two default types: json, stdout.
They are possible to set with the WP_LOGGER_FORMAT variable (stdout is default).
Both of the types will output to the stdout/stderr channel (the terminal) while they will produce either clear text logs or json formatted logs.

If you wish to change the loggers on the logging object, it's possible to do so by querying the logger and add (or remove) loggers from it. Multiple loggers can be added:

jitesoft('logger')->removeLogger('stdout');
jitesoft('logger')->removeLogger('json');

jitesoft('logger')->addLogger(new MyPsrLogger(), 'myLogger');

Or directly in the hook:

add_action('jitesoft_logger_loaded', static function($logger) {
    $logger->removeLogger('stdout');
    $logger->removeLogger('json');
    $logger->addLogger(new MyPsrLogger(), 'myLogger');
});

Installation

Use a composer based WordPress installation and require this plugin.

Loggers

If you wish to add more loggers, the package depends on the jitesoft/loggers php package, which contains multiple different loggers.
If you wish to use your own loggers, the logger must implement the PSR-3 logger interface.

License

MIT!

You might also like...
Verify purchase codes right on your WordPress dashboard.
Verify purchase codes right on your WordPress dashboard.

envato-purchase-code-widget Verify purchase codes right on your WordPress dashboard. Install the plugin Go to Settings-EPCW and enter your "Envato AP

A library that improve your WordPress development experience. 🚀

UYCore WordPress The main idea of the UYCore WordPress library is to decrease development time and have enjoyed the development process. The UYCore li

This is a clone of Discord's homepage built using Wordpress.
This is a clone of Discord's homepage built using Wordpress.

Discord-UI-Clone Description This is a clone of Discord's homepage built using Wordpress, it is configured to run on the Pantheon platform. Live Demo

Run your WP site on github pages, php innovation award winner  https://www.phpclasses.org/package/12091-PHP-Make-a-WordPress-site-run-on-GitHub-pages.html
Run your WP site on github pages, php innovation award winner https://www.phpclasses.org/package/12091-PHP-Make-a-WordPress-site-run-on-GitHub-pages.html

Gitpress Run wordpress directly on github pages Gitpress won the innovation award for may 2021 Read more about this https://naveen17797.github.io/gitp

A WordPress package to nudge users to upgrade their software versions (starting with PHP)
A WordPress package to nudge users to upgrade their software versions (starting with PHP)

whip A WordPress package to nudge users to upgrade their software versions (starting with PHP) Requirements The following versions of PHP are supporte

Learn how to run WordPress with Docker. Read about our experiences and start off with an easy boilerplate.
Learn how to run WordPress with Docker. Read about our experiences and start off with an easy boilerplate.

Hi! We're Dan and Jay. We're a two person team with a passion for open source products. We created Server Side Up to help share what we learn. Find us

A FREE Wordpress Plugin to compress and convert images using cwebp, jpegoptim and optipng.
A FREE Wordpress Plugin to compress and convert images using cwebp, jpegoptim and optipng.

Squidge Is FREE WordpPress Plugin built for developers in mind compressing and convert images using jpegoptim, optipng, cwebp, and libavif. It's extre

WordPress Packagist — manage your plugins with Composer

WordPress Packagist This is the repository for wpackagist.org which allows WordPress plugins and themes to be managed along with other dependencies us

CloudFlare Image Resizing plugin for WordPress.

Cloudflare Image Resizing plugin for WordPress The current Cloudflare plugin for WordPress does not replace URL's automatically for you to use the Ima

Releases(1.3.0)
Owner
Jitesoft
Jitesoft company GitHub group.
Jitesoft
Add a logger to your Kirby3 website

A Website logger for Kirby3 Commercial Usage This plugin is free but if you use it in a commercial project please consider to buy me a ?? Installation

Michael Scheurich 13 Nov 27, 2022
Magento 2 Email Catcher or Email Logger Module. Available At Packagist.

Magento 2 Module Experius email catcher / - logger ``experius/module-emailcatcher`` Main Functionalities Installation Versions Enable email catcher C

Experius 53 Dec 18, 2022
⚙️ A WordPress plugin to set WordPress options from a .env file.

dotenv A WordPress plugin to set WordPress options from a .env file. Any WPENV_ prefixed variables in the .env will be used to override the WordPress

Brad Parbs 13 Oct 6, 2022
WordPlate is a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

WordPlate is simply a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

WordPlate 1.7k Dec 24, 2022
Thirdweb-wp - A community WordPress plugin for thirdweb. Turn your WordPress website into Web3 instantly and easily with thirdweb. 💻🌏

Thirdweb WP ?? Nominate (@WarenGonzaga) as GitHub Star. If you appreciate his hardwork and dedication to open source. A community WordPress plugin for

Waren Gonzaga 8 Dec 19, 2022
Api.video-wordpress-plugin - The official api.video plugin for WordPress

api.video WordPress Plugin api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managin

api.video 5 Oct 19, 2022
A simple GitScrum plugin for Wordpress. You will be able to manage your projects without having to leave Wordpress.

GitScrum Plugin for Wordpress A simple GitScrum plugin for Wordpress. You will be able to manage your projects without having to leave Wordpress. GitS

GitScrum 4 Nov 30, 2022
RRR makes structured data for WordPress really rich, and really easy.

Really Rich Results - JSON-LD Structured Data (Google Rich Results) for WordPress Search engines are putting more weight on structured data than ever

Pagely 22 Dec 1, 2022
⚡️ A WordPress plugin to quickly send a 404 for missing static files

Static 404 A WordPress plugin to quickly send a 404 for missing static files. Quickly output a 404 for static files that aren't found, rather than loa

Brad Parbs 26 Oct 6, 2022