pear/log
PEAR Log provides a simple, standardized logging system for PHP. It supports multiple backends (file, console, syslog, database, mail, etc.), configurable priorities and formatting, and a consistent API to route application messages wherever you need.
pear/log lacks PSR-3 compliance, requiring custom adapters or wrappers to integrate with Laravel’s Log facade.['user_id' => 123]). Incompatible with Laravel’s Log::withContext() or Log::structured().classmap or autoload-dev configuration to avoid collisions.single, daily) cannot natively use pear/log handlers.whenDebugging() or onlyInProduction() require manual implementation.PEAR_LOG_ALL mask issues on 32-bit systems #41). Potential edge-case bugs in production.pear/pear_exception dependency may conflict with Laravel’s error handling or other PEAR packages.pear/log won’t integrate with Laravel’s exception handlers (e.g., App\Exceptions\Handler).pear/log stagnates? Will the team migrate to Monolog or another PSR-3 logger?pear/log?Phase 1: Isolated Pilot (1–2 Weeks)
pear/log in a non-production Laravel environment.Log::info() with a wrapper class to normalize API differences:
class PearLoggerAdapter {
public static function log(string $level, string $message, array $context = []) {
$pearLevel = match ($level) {
'debug' => PEAR_LOG_DEBUG,
'info' => PEAR_LOG_INFO,
// ... other mappings
default => PEAR_LOG_NOTICE,
};
$logger = PEAR::log();
$logger->log($message . (empty($context) ? '' : ' | ' . json_encode($context)), $pearLevel);
}
}
Phase 2: Limited Integration (2–4 Weeks)
// config/logging.php
'pear' => [
'driver' => 'custom',
'path' => storage_path('logs/pear.log'),
'level' => 'debug',
'handler' => new \PEAR\Log\Handler\File(storage_path('logs/pear.log')),
],
Phase 3: Full Integration (4–8 Weeks)
pear/log to enable Laravel’s Log facade:
class PearHandler implements \Monolog\Handler\HandlerInterface {
public function handle(array $record): bool {
$level = match ($record['level']) {
\Monolog\Logger::DEBUG => PEAR_LOG_DEBUG,
// ...
};
PEAR::log()->log($record['message'], $level);
return true;
}
// Implement other Monolog methods...
}
$logger->pushHandler(new PearHandler());
pear/log and gradually migrate to Monolog by:
pear/log calls with Monolog in new code.Phase 4: Deprecation (Ongoing)
pear/log as a legacy dependency in composer.json.pear/log with Laravel’s native logger in all new code.debug → PEAR_LOG_DEBUG).$logger->log("User action | " . json_encode($context), PEAR_LOG_INFO);
pear/log:
Log::channel('pear')->info('Legacy log message');
pear_exception and rethrow as Laravel exceptions:
try {
PEAR::log()->log($message, $level);
} catch (\PEAR_Exception $e) {
throw new \RuntimeException("Logging failed: " . $e->getMessage());
}
pear/pear_exception is installed (v1.0.1–1.0.2).autoload-dev:
{
"autoload-dev": {
"psr-4": {
"PEAR\\": "vendor/pear/log/src/"
}
}
}
Step 1: Dependency Audit
pear/log.Step 2: API Alignment
info(), error()).Step 3: Handler Expansion
How can I help you explore Laravel packages today?