private function setupLogging()
 {
     $this->logger = Logger::getLogger('Panopta API');
     $this->logger->setLevel($this->logLevel == LOG_INFO ? LoggerLevel::getLevelInfo() : LoggerLevel::getLevelDebug());
     $logAppender = new LoggerAppenderDailyFile();
     $logAppender->setFile(rtrim(rtrim($this->logPath, "/"), "\\") . DIRECTORY_SEPARATOR . "panopta_api.log");
     $logAppender->setAppend(true);
     $logAppender->setDatePattern("yyyy-MM-dd'.log'");
     $logAppender->setThreshold($this->logLevel);
     $pattern = new LoggerLayoutPattern();
     $pattern->setConversionPattern("%date - %logger - %level - %message%newline");
     $logAppender->setLayout($pattern);
     $logAppender->activateOptions();
     $this->logger->addAppender($logAppender);
 }
 public function configure(\LoggerHierarchy $hierarchy, $input = null)
 {
     global $configuration;
     /*******************************************
      * For Main
      *******************************************/
     // Create an appender for Main Transactions.
     $mainTransAppender = new \LoggerAppenderDailyFile('mainTransAppender');
     $mainTransAppender->setLayout(new \LoggerLayoutSimple());
     $mainTransAppender->setFile($configuration->log['mainTransFile']);
     $mainTransAppender->setDatePattern('Y-m-d');
     // Create an appender for Main Errors.
     $mainErrorAppender = new \LoggerAppenderDailyFile('mainErrorAppender');
     $mainErrorAppender->setLayout(new \LoggerLayoutSimple());
     $mainErrorAppender->setFile($configuration->log['mainErrorFile']);
     $mainErrorAppender->setDatePattern('Y-m-d');
     //Create Main Loggers.
     $mainTransLogger = $hierarchy->getLogger('mainTransLogger');
     $mainErrorLogger = $hierarchy->getLogger('mainErrorLogger');
     //Assign Main Appenders.
     $mainTransLogger->addAppender($mainTransAppender);
     $mainErrorLogger->addAppender($mainErrorAppender);
 }
 public function testChangedDateFormat()
 {
     $layout = new LoggerLayoutSimple();
     $event = new LoggerLoggingEvent('LoggerAppenderFileTest', new Logger('mycategory'), LoggerLevel::getLevelWarn(), "my message");
     $appender = new LoggerAppenderDailyFile("mylogger");
     $appender->setDatePattern('Y');
     $appender->setFile('../../../target/temp/phpunit/TEST-daily.txt.%s');
     $appender->setLayout($layout);
     $appender->activateOptions();
     $appender->append($event);
     $appender->close();
     $this->t2 = date("Y");
     $v = file_get_contents('../../../target/temp/phpunit/TEST-daily.txt.' . $this->t2);
     $e = "WARN - my message" . PHP_EOL;
     self::assertEquals($e, $v);
 }
 public function testChangedDateFormat()
 {
     $event = LoggerTestHelper::getWarnEvent("my message");
     $appender = new LoggerAppenderDailyFile();
     $appender->setDatePattern('Y');
     $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.%s');
     $appender->activateOptions();
     $appender->append($event);
     $appender->close();
     $actual = file_get_contents(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date("Y"));
     $expected = "WARN - my message" . PHP_EOL;
     self::assertEquals($expected, $actual);
 }