- Add comprehensive health check system with multiple endpoints - Add Prometheus metrics endpoint - Add production logging configurations (5 strategies) - Add complete deployment documentation suite: * QUICKSTART.md - 30-minute deployment guide * DEPLOYMENT_CHECKLIST.md - Printable verification checklist * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference * production-logging.md - Logging configuration guide * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation * README.md - Navigation hub * DEPLOYMENT_SUMMARY.md - Executive summary - Add deployment scripts and automation - Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment - Update README with production-ready features All production infrastructure is now complete and ready for deployment.
79 lines
2.1 KiB
PHP
79 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Test Docker JSON Logging
|
|
*
|
|
* Verify that DockerJsonHandler produces correctly formatted JSON for docker logs
|
|
*/
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\Config\Environment;
|
|
use App\Framework\Logging\DefaultLogger;
|
|
use App\Framework\Logging\Handlers\DockerJsonHandler;
|
|
use App\Framework\Logging\LogLevel;
|
|
use App\Framework\Logging\LogContextManager;
|
|
use App\Framework\Logging\ProcessorManager;
|
|
use App\Framework\Logging\ValueObjects\LogContext;
|
|
|
|
echo "=== Docker JSON Logging Test ===\n\n";
|
|
|
|
// Setup logger with DockerJsonHandler
|
|
$env = new Environment();
|
|
$dockerHandler = new DockerJsonHandler(
|
|
env: $env,
|
|
serviceName: 'test-service',
|
|
minLevel: LogLevel::DEBUG
|
|
);
|
|
|
|
$logger = new DefaultLogger(
|
|
minLevel: LogLevel::DEBUG,
|
|
handlers: [$dockerHandler],
|
|
processorManager: new ProcessorManager(),
|
|
contextManager: new LogContextManager()
|
|
);
|
|
|
|
echo "1. Testing basic log output:\n";
|
|
echo "---\n";
|
|
$logger->info('Application started', LogContext::withData(['version' => '1.0.0']));
|
|
echo "---\n\n";
|
|
|
|
echo "2. Testing different log levels:\n";
|
|
echo "---\n";
|
|
$logger->debug('Debug message');
|
|
$logger->info('Info message');
|
|
$logger->warning('Warning message');
|
|
$logger->error('Error message');
|
|
$logger->critical('Critical message');
|
|
echo "---\n\n";
|
|
|
|
echo "3. Testing with structured context:\n";
|
|
echo "---\n";
|
|
$logger->info('User action', LogContext::withData([
|
|
'user_id' => 12345,
|
|
'action' => 'login',
|
|
'ip_address' => '192.168.1.1',
|
|
'user_agent' => 'Mozilla/5.0'
|
|
]));
|
|
echo "---\n\n";
|
|
|
|
echo "4. Testing with complex context:\n";
|
|
echo "---\n";
|
|
$logger->error(
|
|
'Database error',
|
|
LogContext::withData([
|
|
'query' => 'SELECT * FROM users',
|
|
'error_code' => 'E1234',
|
|
'database' => 'main'
|
|
])
|
|
);
|
|
echo "---\n\n";
|
|
|
|
echo "✅ Docker JSON logging test complete!\n\n";
|
|
echo "Usage:\n";
|
|
echo " docker logs <container> 2>&1 | jq .\n";
|
|
echo " docker logs <container> 2>&1 | jq 'select(.level == \"ERROR\")'\n";
|
|
echo " docker logs <container> 2>&1 | jq -r '[.timestamp, .level, .message] | @tsv'\n";
|