ayaou/command-logger-bundle
Symfony bundle that logs executed console commands with arguments, execution time, exit codes, and errors. Configure via attributes or wildcard patterns, view and filter logs with the command-logger:show command.
command_log table. Laravel’s Eloquent or Query Builder can replace this. v1.11.0 adds opt-in storage of captured command output, which requires an additional output column (likely TEXT/LONGTEXT or JSON) and corresponding Eloquent cast.Artisan::starting/Artisan::finished events or middleware can replicate this behavior.#[CommandLogger] attribute. Laravel can use traits, custom attributes (PHP 8.0+), or annotations for equivalent functionality.command-logger:show. This introduces a new data-capture concern: output may be large, multi-line, or contain sensitive information. Laravel integration must decide whether to buffer Artisan output directly, use Symfony\Component\Console\Output\BufferedOutput, or wrap command execution to capture stdout/stderr.CommandLogger attribute to Laravel’s attribute system or annotations.command_logger.capture_output) and a migration for the output column.command-logger:show equivalent to render captured output (with truncation/formatting).config/ system can mirror this, including the new output-capture opt-in flag. Consider per-command opt-in as well as global enablement.command-logger:show and command-logger:purge commands can be replicated as Laravel Artisan commands. show should gain an option to display captured output (e.g., --output or automatic when present).command_log table schema (timestamps, JSON fields). v1.11.0 adds an output column, requiring a migration and consideration of storage type (TEXT vs. file/object storage) for large outputs.make:*) may not translate directly to Laravel’s command resolution. Custom logic may be needed.spatie/laravel-command, CI logs) meet the need with less effort?arguments; add a TEXT/LONGTEXT column for captured output).Artisan::starting/Artisan::finished events or middleware to intercept commands.BufferedOutput within a wrapper. Expose an opt-in config flag.| Feature | Symfony Implementation | Laravel Adaptation |
|---|---|---|
| Command Registration | #[AsCommand] attribute |
Artisan::command() or #[ConsoleCommand] |
| Event System | console.command events |
Artisan::starting/finished events |
| Configuration | YAML (config/packages/) |
PHP (config/command_logger.php) |
| Database ORM | Doctrine | Eloquent |
| Output Capture | Opt-in flag in v1.11.0 | Opt-in config flag + buffered output |
CommandLog).migrate, queue:work).public function handle($request, Closure $next) {
if ($request->isConsole()) {
$start = microtime(true);
try {
$response = $next($request);
$this->logCommand($request->command, $response->exitCode, null, $start);
} catch (\Exception $e) {
$this->logCommand($request->command, 1, $e->getMessage(), $start);
throw $e;
}
}
return $next($request);
}
output column. Validate that interactive/streaming commands are not broken.// app/Models/CommandLog.php
class CommandLog extends Model {
protected $casts = [
'arguments' => 'json',
'output' => 'string',
];
}
output column (nullable, TEXT/LONGTEXT). Consider a separate table or object storage if output volume is high.config/ system, including capture_output and per-command allowlists.#[LogCommand]) with optional output capture.command-logger:show, command-logger:purge) as Artisan commands. Extend show to render captured output with truncation and optional --output flag.show command (e.g., --error, --success, --with-output).make:*) may need custom logic for Laravel’s command loader.command_log schema.output column migration before enabling capture in any environment.command-logger:show and command-logger:purge last (depends on storage layer). Include output rendering and redaction.config/command_logger.php (e.g., enabled, purge threshold, command whitelist, capture_output, output truncation limit).config:cache to optimize performance.exitCode: 1, errorMessage).migrate failure in CI by inspecting both the exit code and the captured error output.command-logger:show --error helps identify flaky commands.command-logger:show --with-output helps inspect command stdout/stderr.#[LogCommand]).php artisan command-logger:show --limit=20 --with-output).README.md section for Laravel integration, including a security note about sensitive output.queue:work). Output capture may need to be synchronous or buffered before dispatch.startTime and commandName for fast queries in command-logger:show. Output column increases row size; consider separate storage if large.How can I help you explore Laravel packages today?