Skip to content

Recording Command Output

By default, Laritor captures basic information about Artisan commands, including their name, start and end times, exit code, and context. To also record a command’s output, enable it on that command with the SendOutputToLaritor trait.

Add the trait to your console command class:

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use BinaryBuilds\LaritorClient\SendOutputToLaritor;
class ImportUsers extends Command
{
use SendOutputToLaritor;
protected $signature = 'users:import';
protected $description = 'Import users from external service';
public function handle()
{
$this->info('Starting import...');
// Import logic here
$this->info('Import complete!');
}
}

Laritor will capture the command’s console output, including info, warn, error, comment, table, and other console messages, as part of the command event data.

  • Debugging failed or complex long-running commands.
  • Correlating command logs with system events.