WordPress Plugin
LogHub also provides a WordPress plugin that makes integrating logging into your WordPress site seamless and easy. The plugin provides the LogHub class that you can use to send logs from within WordPress.
How to Install the LogHub WordPress Plugin
- Download the Plugin: Navigate to the Getting Started section of the LogHub dashboard and download the WordPress plugin as a ZIP file.
- Install the Plugin:
- In your WordPress admin dashboard, go to Plugins → Add New.
- Click Upload Plugin at the top of the page.
- Choose the downloaded ZIP file, then click Install Now.
- Activate the Plugin: Once the plugin is installed, click Activate to enable it on your WordPress site.
Once activated, the plugin provides access to the LogHub Class, which you can use to log directly from your WordPress theme or plugins.
Log actions from WordPress to LogHub
To get started, navigate to Settings > LogHub in your dashboard. Here, you can configure your API_KEY and specify the actions you want to log in LogHub. Once set up, all parameters from these actions will automatically be sent to LogHub for easy tracking and analysis.
Log custom events in WordPress to LogHub
Whether using the REST API or WordPress plugin, you can start capturing logs and monitoring your projects with ease using LogHub.
LogHub::init('YOUR_API_KEY');
$parent_id = LogHub::log('function-name', 'actual log content can be text, json, array or class instances');
LogHub::log('function-name', 'log child element', LogHub::TYPE_ERROR, parent: $parent_id);
LogHub::startTimer('timer-name');
sleep(2);
LogHub::endTimer('timer-name');
// If you already have a fixed timer measurement:
LogHub::sendTimer('timer-fixed-355', 3.55);