PHP code example of kynetcode / wpzylos-logger

1. Go to this page and download the library: Download kynetcode/wpzylos-logger 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/ */

    

kynetcode / wpzylos-logger example snippets


$app->register(new \WPZylos\Framework\Logger\LoggerServiceProvider());

use Psr\Log\LoggerInterface;

$logger = $app->make(LoggerInterface::class);
// or: $app->make('log');
// or: $app->make('logger');

$logger->info('User {name} logged in', ['name' => 'John']);
$logger->error('Payment failed', ['order_id' => 456]);

use WPZylos\Framework\Logger\Logger;

$logger = new Logger($context, null, 'warning');
$logger->warning('Low disk space');

$logger->emergency('System is unusable');
$logger->alert('Action must be taken immediately');
$logger->critical('Critical conditions');
$logger->error('Error conditions');
$logger->warning('Warning conditions');
$logger->notice('Normal but significant condition');
$logger->info('Informational messages');
$logger->debug('Debug-level messages');

$logger->info('Order placed', [
    'order_id' => $order->id,
    'user_id' => $user->id,
    'total' => $order->total,
]);

// Logs written to: wp-content/uploads/{slug}/logs/2025-01-15.log
$logger->info('Application started');

// Clean old logs (30 days default)
$deleted = $logger->cleanOldLogs(30);