Loading config/autoload/global.php +0 −3 Original line number Diff line number Diff line Loading @@ -228,9 +228,6 @@ return array( 'timesheet_modele' => realpath(__DIR__.'/../../data/timesheet_model.xls'), ], 'log_path' => __DIR__ . '/../../logs/oscar.log', 'log_level' => \Monolog\Logger::WARNING, 'generated-documents' => [ 'activity' => [] ], Loading module/Oscar/src/Oscar/Command/OscarCheckLoggerCommand.php +6 −2 Original line number Diff line number Diff line Loading @@ -67,13 +67,17 @@ class OscarCheckLoggerCommand extends OscarCommandAbstract $io->text("Envoi : <bold>$msg</bold> dans les logs"); $logger->debug($msg); $msg = "Niveau INFO loggué"; $io->text("Envoi : <bold>$msg</bold> dans les logs"); $logger->info($msg); $msg = "Niveau NOTICE loggué"; $io->text("Envoi : <bold>$msg</bold> dans les logs"); $logger->notice($msg); $msg = "Niveau INFO loggué"; $msg = "Niveau WARNING loggué"; $io->text("Envoi : <bold>$msg</bold> dans les logs"); $logger->info($msg); $logger->warning($msg); $msg = "Niveau ALERT loggué"; $io->text("Envoi : <bold>$msg</bold> dans les logs"); Loading module/Oscar/src/Oscar/Controller/PublicController.php +0 −2 Original line number Diff line number Diff line Loading @@ -172,9 +172,7 @@ class PublicController extends AbstractOscarController implements UseTimesheetSe */ public function indexAction() { $this->getLoggerService()->debug("indexAction"); $person = null; $validations = []; $isValidator = false; $person = $this->getOscarUserContextService()->getCurrentPerson(); Loading module/Oscar/src/Oscar/Service/LoggerServiceFactory.php +21 −4 Original line number Diff line number Diff line Loading @@ -11,6 +11,9 @@ namespace Oscar\Service; use Interop\Container\ContainerInterface; use Interop\Container\Exception\ContainerException; use Monolog\Handler\FirePHPHandler; use Monolog\Handler\StreamHandler; use Monolog\Logger; use Oscar\Exception\OscarException; use Zend\ServiceManager\Exception\ServiceNotCreatedException; use Zend\ServiceManager\Exception\ServiceNotFoundException; Loading @@ -20,8 +23,16 @@ class LoggerServiceFactory implements FactoryInterface { public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $logPath = $container->get(OscarConfigurationService::class)->getConfiguration('log_path'); $logLevel = $container->get(OscarConfigurationService::class)->getConfiguration('log_level'); // --- CONF : issue de /config/autoload/global.php et /config/autoload/local.php /** @var OscarConfigurationService $configurationService */ $configurationService = $container->get(OscarConfigurationService::class); // Emplacement du fichier de log $logPath = $configurationService->getLoggerFilePath(); // Niveau de log $logLevel = $configurationService->getLoggerLevel(); if( !file_exists($logPath) ){ $handler = fopen($logPath, 'w'); Loading @@ -36,8 +47,14 @@ class LoggerServiceFactory implements FactoryInterface throw new OscarException("Le fichier de log n'est pas accessible en écriture"); } $logger = new \Monolog\Logger('oscar'); $logger->pushHandler(new \Monolog\Handler\StreamHandler($logPath, $logLevel)); // Sorties des logs (fichier + PHP stdrout) $stream = new StreamHandler($logPath, $logLevel); $firephp = new FirePHPHandler($logLevel); $logger = new Logger('oscar'); $logger->pushHandler($stream); $logger->pushHandler($firephp); return $logger; } } module/Oscar/src/Oscar/Service/OscarConfigurationService.php +15 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ namespace Oscar\Service; use Monolog\Logger; use Oscar\Exception\OscarException; use Oscar\Formatter\File\IHtmlToPdfFormatter; use Oscar\Import\Data\DataStringArray; Loading Loading @@ -82,6 +83,20 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface ]); } /** * @return string */ public function getLoggerFilePath() :string { return $this->getOptionalConfiguration('log_path', __DIR__.'/../../../../../logs/oscar.log'); } /** * @return string */ public function getLoggerLevel() :int { return $this->getOptionalConfiguration('log_level', Logger::WARNING); } /** * @param $key Loading Loading
config/autoload/global.php +0 −3 Original line number Diff line number Diff line Loading @@ -228,9 +228,6 @@ return array( 'timesheet_modele' => realpath(__DIR__.'/../../data/timesheet_model.xls'), ], 'log_path' => __DIR__ . '/../../logs/oscar.log', 'log_level' => \Monolog\Logger::WARNING, 'generated-documents' => [ 'activity' => [] ], Loading
module/Oscar/src/Oscar/Command/OscarCheckLoggerCommand.php +6 −2 Original line number Diff line number Diff line Loading @@ -67,13 +67,17 @@ class OscarCheckLoggerCommand extends OscarCommandAbstract $io->text("Envoi : <bold>$msg</bold> dans les logs"); $logger->debug($msg); $msg = "Niveau INFO loggué"; $io->text("Envoi : <bold>$msg</bold> dans les logs"); $logger->info($msg); $msg = "Niveau NOTICE loggué"; $io->text("Envoi : <bold>$msg</bold> dans les logs"); $logger->notice($msg); $msg = "Niveau INFO loggué"; $msg = "Niveau WARNING loggué"; $io->text("Envoi : <bold>$msg</bold> dans les logs"); $logger->info($msg); $logger->warning($msg); $msg = "Niveau ALERT loggué"; $io->text("Envoi : <bold>$msg</bold> dans les logs"); Loading
module/Oscar/src/Oscar/Controller/PublicController.php +0 −2 Original line number Diff line number Diff line Loading @@ -172,9 +172,7 @@ class PublicController extends AbstractOscarController implements UseTimesheetSe */ public function indexAction() { $this->getLoggerService()->debug("indexAction"); $person = null; $validations = []; $isValidator = false; $person = $this->getOscarUserContextService()->getCurrentPerson(); Loading
module/Oscar/src/Oscar/Service/LoggerServiceFactory.php +21 −4 Original line number Diff line number Diff line Loading @@ -11,6 +11,9 @@ namespace Oscar\Service; use Interop\Container\ContainerInterface; use Interop\Container\Exception\ContainerException; use Monolog\Handler\FirePHPHandler; use Monolog\Handler\StreamHandler; use Monolog\Logger; use Oscar\Exception\OscarException; use Zend\ServiceManager\Exception\ServiceNotCreatedException; use Zend\ServiceManager\Exception\ServiceNotFoundException; Loading @@ -20,8 +23,16 @@ class LoggerServiceFactory implements FactoryInterface { public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $logPath = $container->get(OscarConfigurationService::class)->getConfiguration('log_path'); $logLevel = $container->get(OscarConfigurationService::class)->getConfiguration('log_level'); // --- CONF : issue de /config/autoload/global.php et /config/autoload/local.php /** @var OscarConfigurationService $configurationService */ $configurationService = $container->get(OscarConfigurationService::class); // Emplacement du fichier de log $logPath = $configurationService->getLoggerFilePath(); // Niveau de log $logLevel = $configurationService->getLoggerLevel(); if( !file_exists($logPath) ){ $handler = fopen($logPath, 'w'); Loading @@ -36,8 +47,14 @@ class LoggerServiceFactory implements FactoryInterface throw new OscarException("Le fichier de log n'est pas accessible en écriture"); } $logger = new \Monolog\Logger('oscar'); $logger->pushHandler(new \Monolog\Handler\StreamHandler($logPath, $logLevel)); // Sorties des logs (fichier + PHP stdrout) $stream = new StreamHandler($logPath, $logLevel); $firephp = new FirePHPHandler($logLevel); $logger = new Logger('oscar'); $logger->pushHandler($stream); $logger->pushHandler($firephp); return $logger; } }
module/Oscar/src/Oscar/Service/OscarConfigurationService.php +15 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ namespace Oscar\Service; use Monolog\Logger; use Oscar\Exception\OscarException; use Oscar\Formatter\File\IHtmlToPdfFormatter; use Oscar\Import\Data\DataStringArray; Loading Loading @@ -82,6 +83,20 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface ]); } /** * @return string */ public function getLoggerFilePath() :string { return $this->getOptionalConfiguration('log_path', __DIR__.'/../../../../../logs/oscar.log'); } /** * @return string */ public function getLoggerLevel() :int { return $this->getOptionalConfiguration('log_level', Logger::WARNING); } /** * @param $key Loading