Skip to content

Commit 49a0a28

Browse files
committed
Update scratch package and use logger
1 parent 42361c1 commit 49a0a28

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
"doctrine/dbal": "^2.6",
2020
"illuminate/database": "^5.6 | ^6",
2121
"illuminate/events": "^5.6 | ^6",
22+
"illuminate/log": "^5.6 | ^6",
2223
"illuminate/view": "^5.6 | ^6",
23-
"laravel-bridge/scratch": "^0.2",
24+
"laravel-bridge/scratch": "^0.3",
2425
"mikey179/vfsstream": "^1.6",
26+
"monolog/monolog": "^1.25",
2527
"symfony/console": "^4 | ^5",
2628
"symfony/yaml": "^4 | ^5",
2729
"vlucas/phpdotenv": "^3"

src/Commands/GenerateCommand.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace MilesChou\Schemarkdown\Commands;
44

5+
use Illuminate\Log\LogManager;
6+
use Illuminate\Support\Facades\Log;
57
use MilesChou\Schemarkdown\Commands\Concerns\Environment;
68
use Illuminate\Container\Container;
79
use Illuminate\Database\DatabaseManager;
@@ -11,6 +13,7 @@
1113
use Symfony\Component\Console\Command\Command;
1214
use Symfony\Component\Console\Input\InputInterface;
1315
use Symfony\Component\Console\Input\InputOption;
16+
use Symfony\Component\Console\Logger\ConsoleLogger;
1417
use Symfony\Component\Console\Output\OutputInterface;
1518

1619
class GenerateCommand extends Command
@@ -34,6 +37,24 @@ public function __construct(Container $container, string $name = null)
3437
$this->container = $container;
3538
}
3639

40+
protected function initialize(InputInterface $input, OutputInterface $output)
41+
{
42+
$loggerName = 'schemarkdown';
43+
44+
$this->container['config']['logging.default'] = $loggerName;
45+
$this->container['config']["logging.channels.{$loggerName}"] = [
46+
'driver' => $loggerName,
47+
];
48+
49+
/** @var LogManager $loggerManager */
50+
$loggerManager = $this->container->make('log');
51+
$loggerManager->extend($loggerName, function () use ($output) {
52+
return new ConsoleLogger($output);
53+
});
54+
55+
$loggerManager->setDefaultDriver($loggerName);
56+
}
57+
3758
protected function configure()
3859
{
3960
parent::configure();

0 commit comments

Comments
 (0)