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: 4.0 or higher
- PHP version: 5.6 or higher
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:
Code language: Bash (bash)
composer require perfopsone/decalog
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:
Code language: PHP (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 theme use this: \DecaLog\Engine::initTheme( 'my-theme-slug', 'My Theme Name', '1.0.0' );
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).