22
33namespace MilesChou \Schemarkdown \Commands ;
44
5+ use Illuminate \Log \LogManager ;
6+ use Illuminate \Support \Facades \Log ;
57use MilesChou \Schemarkdown \Commands \Concerns \Environment ;
68use Illuminate \Container \Container ;
79use Illuminate \Database \DatabaseManager ;
1113use Symfony \Component \Console \Command \Command ;
1214use Symfony \Component \Console \Input \InputInterface ;
1315use Symfony \Component \Console \Input \InputOption ;
16+ use Symfony \Component \Console \Logger \ConsoleLogger ;
1417use Symfony \Component \Console \Output \OutputInterface ;
1518
1619class 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