PHP code example of wp-spaghetti / wonolog-handler
1. Go to this page and download the library: Download wp-spaghetti/wonolog-handler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Illuminate\Support\Facades\Log;
// Anywhere in your Laravel + WordPress code
Log::debug('Debugging information');
Log::info('Informational message');
Log::notice('Normal but significant event');
Log::warning('Warning condition');
Log::error('Error condition');
Log::critical('Critical condition');
Log::alert('Action must be taken immediately');
Log::emergency('System is unusable');
Log::error('Payment failed', [
'user_id' => $userId,
'amount' => $amount,
'error' => $exception->getMessage(),
]);
// Wonolog channels - use UPPERCASE by convention
Log::error('Security breach', [
'channel' => 'SECURITY', // ✅ Correct
'ip' => $ipAddress,
]);
// Avoid lowercase - may not be tracked
// Log::error('Breach', ['channel' => 'security']); // ❌ May not work
// Use only Wonolog (no file backup)
Log::channel('wonolog')->error('Critical error');
// Use only file logging
Log::channel('single')->debug('Debug info');
// Use stack (Wonolog + file) - recommended
Log::channel('stack')->warning('Warning message');
// In app/Controllers/App.php or any controller
use Illuminate\Support\Facades\Log;
public function index()
{
Log::info('Page viewed', ['url' => request()->url()]);
return $this->view;
}
// In your custom plugins or theme
use Illuminate\Support\Facades\Log;
add_action('init', function() {
Log::info('WordPress initialized');
});
use Corcel\Model\Post;
use Illuminate\Support\Facades\Log;
$posts = Post::published()->get();
Log::info('Fetched posts', ['count' => $posts->count()]);