bramus/monolog-colored-line-formatter
Adds a colored line formatter for Monolog, making console log output easier to scan with ANSI colors. Works as a drop-in formatter to highlight log levels, timestamps, and messages for CLI tools, workers, and development environments.
Enhanced Developer Productivity:
ERROR in red, INFO in blue) in Laravel’s CLI-driven workflows (Artisan, Tinker, Sail).Strategic Roadmap Alignment:
Use Cases:
sail artisan migrate) more intuitive with color-coded status messages.ERROR in red, SUCCESS in green).Adopt if:
DEBUG, ERROR, INFO) and require quick visual scanning to triage issues.Look elsewhere if:
Psr\Log adapters)."This package transforms how our developers debug Laravel applications by adding color to log output—turning a wall of text into a skimmable, visually intuitive experience. For example, errors pop in red, warnings in yellow, and debug logs in gray, so issues are spotted instantly during local development or CI builds. It’s a no-code upgrade that reduces debugging time by 15–25% (based on anecdotal feedback from similar tools), with minimal engineering effort. Since it’s MIT-licensed and open-source, we can customize it further if needed, like adding our brand colors or log prefixes. The cost is zero, and the payoff is faster releases and happier developers."
ROI Highlights:
"The bramus/monolog-colored-line-formatter adds ANSI colors to Monolog logs, making them far more readable in terminals, IDEs, and CI/CD outputs. Here’s how to implement it in Laravel:
Installation:
composer require bramus/monolog-colored-line-formatter
Configuration:
Replace or extend your Monolog formatter in config/logging.php or a service provider:
'handlers' => [
'colored' => [
'class' => Monolog\Handler\StreamHandler::class,
'formatter' => Bramus\Monolog\Formatter\ColoredLineFormatter::class,
'stream' => storage_path('logs/laravel.log'),
'level' => Monolog\Logger::DEBUG,
],
],
For Laravel-specific setups, use a service provider to conditionally apply the formatter:
// app/Providers/AppServiceProvider.php
public function boot()
{
if (app()->environment('local')) {
$this->app['log']->stack(function ($stack) {
$stack->push(
(new Monolog\Handler\StreamHandler(storage_path('logs/laravel.log')))
->setFormatter(new Bramus\Monolog\Formatter\ColoredLineFormatter())
);
});
}
}
Key Benefits:
setColors() or subclassing.MemoryPeakUsageProcessor).Trade-offs:
Proposal: Pilot this in the Laravel monorepo for local development first, then expand to CI/CD pipelines. Pair with a doc update on ‘Debugging with Colored Logs’ and a note about ANSI-safe log sharing for production."*
Tech Debt Note:
How can I help you explore Laravel packages today?