1. Go to this page and download the library: Download illuminated/console-logger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
illuminated / console-logger example snippets
use Illuminated\Console\Loggable;
class ExampleCommand extends Command
{
use Loggable;
public function handle()
{
$this->logInfo('Hello World!');
}
// ...
}
class ExampleCommand extends Command
{
use Loggable;
protected function getLogPath()
{
return storage_path('logs/custom-folder/date.log');
}
protected function getLogMaxFiles()
{
return 45;
}
// ...
}
class ExampleCommand extends Command
{
use Loggable;
protected function useEmailNotificationsDeduplication()
{
return true;
}
protected function getEmailNotificationsDeduplicationTime()
{
return 90;
}
// ...
}
class ExampleCommand extends Command
{
use Loggable;
protected function useDatabaseNotifications()
{
return true;
}
// ...
}
class ExampleCommand extends Command
{
use Loggable;
protected function useDatabaseNotifications()
{
return true;
}
protected function getDatabaseNotificationsTable()
{
return 'custom_notifications';
}
protected function getDatabaseNotificationsCallback()
{
return function (array $record) {
CustomNotification::create([
'level' => $record['level'],
'level_name' => $record['level_name'],
'message' => $record['message'],
'context' => get_dump($record['context']),
'custom_field' => 'Foo Bar Baz!',
]);
};
}
// ...
}
use Illuminated\Console\Exceptions\RuntimeException;
class ExampleCommand extends Command
{
use Loggable;
public function handle()
{
throw new RuntimeException('Whoops! We have a problem!', [
'some' => 123,
'extra' => true,
'context' => null,
]);
}
// ...
}
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
// Create a log middleware
$logMiddleware = iclogger_guzzle_middleware($logger);
// Add it to the HandlerStack
$handler = HandlerStack::create();
$handler->push($logMiddleware);
// Use the created handler in your Guzzle Client
$client = new Client([
'handler' => $handler,
'base_uri' => 'https://example.com',
]);
// Now, all your HTTP requests and responses would be logged automatically!
// $client->get('/foo');
class ExampleCommand extends Command
{
use Loggable;
protected function initialize(InputInterface $input, OutputInterface $output)
{
// You have to call it first
$this->initializeLogging();
// Then goes your custom code
$this->foo = $this->argument('foo');
$this->bar = $this->argument('bar');
$this->baz = $this->argument('baz');
}
// ...
}
class ExampleCommand extends Command
{
use Loggable;
use WithoutOverlapping;
// ...
}
class ExampleCommand extends Command
{
use Loggable;
use WithoutOverlapping;
protected function initialize(InputInterface $input, OutputInterface $output)
{
// Initialize conflicting traits
$this->initializeMutex();
$this->initializeLogging();
}
// ...
}