Added logging.
This commit is contained in:
36
src/App.php
Normal file
36
src/App.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace App;
|
||||
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
|
||||
|
||||
class App {
|
||||
protected Logger $logger;
|
||||
protected array $config;
|
||||
|
||||
function __construct(string $configFile)
|
||||
{
|
||||
$this->config = Yaml::parseFile($configFile);
|
||||
|
||||
$logger = new Logger('app');
|
||||
$logger->pushHandler(new StreamHandler($this->getConfig()['logging']['stream']));
|
||||
$logger->info("Initialization complete");
|
||||
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
||||
function getConfig() : array
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
function getLogger() : Logger
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user