WordPress DecaLog SDK is a way to use DecaLog, the free observability toolkit for WordPress, in your own plugins or themes.
You may use this SDK on all WordPress installations: if DecaLog is installed your users will take advantage of all the efforts you’ve made to report events and provide metrics or traces inside your plugin or theme; if DecaLog is not installed, the SDK will silently discard all these important information …
Deploying WordPress DecaLog SDK
Like DecaLog itself, this SDK is ready to be used in production environments. So you don’t have to worry about cleaning up before deployment. In fact, it’s a good idea to leave it in production: if the installation target runs DecaLog, the users of your plugin or themes will benefit of full observability; if it’s not installed, it will be totally invisible to them.
If your plugin or theme is working on the development environment where you’ve installed DecaLog it will work on all your users’ environments – whether DecaLog is installed or not, assuming the following requirements:
- WordPress version:?6.1 or higher
- PHP version:?8.1 or higher
- PSR-3 version: 3.x
Note: as this SDK is MIT-Licensed, there is no need to worry about leaving it as is in plugins or themes you want to submit to the WordPress directory.
Installing WordPress DecaLog SDK
Thanks to composer, the installation of the sdk requires one command:
composer require perfopsone/decalog
Code language: Bash (bash)
Initializing WordPress DecaLog SDK
Once added to your project and before using it, you need to initialize the SDK. This should be done as soon as possible. For a plugin, for example, you can do it in the first lines of the main file.
Here is a typical initilializing sequence:
<?php
require_once __DIR__ . '/vendor/autoload.php';
// If you're developing a plugin use this:
\DecaLog\Engine::initPlugin( 'my-plugin-slug', 'My Plugin Name', '1.0.0' );
// If you're developing a library use this:
\DecaLog\Engine::initLibrary( 'my-library-slug', 'My Library Name', '1.0.0' );
// If you're developing a theme use this:
\DecaLog\Engine::initTheme( 'my-theme-slug', 'My Theme Name', '1.0.0' );
Code language: PHP (php)
Note: the initPlugin()
, initLibrary()
and initTheme()
methods accept a fourth argument which is optional but recommended: the base64-encoded image for the logo of your plugin or theme (preferably an SVG image, because it may be used in different places at different sizes).