コード例 #1
0
ファイル: LogFile.php プロジェクト: lucasnpinheiro/exception
 /**
  * Gathers informations about Server, execution environment, occured errors
  * and creates log files
  */
 public function createLogFile()
 {
     $logDir = Conf::get('logFileDir');
     if (is_writable($logDir) && Conf::get('createLogFile')) {
         $logDisplayArray = $this->loadLogDisplay();
         $header = "ignaszak/exception - https://github.com/ignaszak/\n" . sprintf("%-17.17s %s", "Date:", date('F d Y H:i:s')) . "\n" . sprintf("%-17.17s %s", "Reported errors:", $logDisplayArray['errorsCount']);
         $globalVars = Variable::getFormatedServerDataAsString();
         $content = strip_tags("{$header}\n\n\n{$globalVars}\n\n\n{$logDisplayArray['errors']}");
         $fileName = date('Y_m_d_H_i_s_u', time()) . '.log';
         file_put_contents("{$logDir}/{$fileName}", $content);
         chmod("{$logDir}/{$fileName}", 0664);
     }
 }
コード例 #2
0
ファイル: Display.php プロジェクト: lucasnpinheiro/exception
 /**
  * @return string
  */
 private function getServerData() : string
 {
     return str_replace("\n", "<br>", str_replace(" ", "&nbsp;", Variable::getFormatedServerDataAsString()));
 }
コード例 #3
0
 public function testFormatVariableType()
 {
     $formatVariableType = array(Variable::formatVariableType(1), Variable::formatVariableType('string', "'"), Variable::formatVariableType(array(1 => 1, 2 => 2)), Variable::formatVariableType(new \Exception('test')), Variable::formatVariableType(fopen(__FILE__, "r")));
     $array = array(1, '\'string\'', print_r(array(1 => 1, 2 => 2), true), '(object) Exception', '(resource) stream');
     $this->assertEquals($array, $formatVariableType);
 }
コード例 #4
0
ファイル: Handler.php プロジェクト: ignaszak/php-exception
 /**
  * Returns formated arguments as string
  *
  * @param mixed $args
  * @return string
  */
 private function getFunctionArgs($args) : string
 {
     if (!is_array($args)) {
         $args = array($args);
     }
     $array = array();
     foreach ($args as $value) {
         $array[] = Variable::formatVariableType(@$value, "'");
     }
     return implode(', ', $array);
 }
コード例 #5
0
 public function testUnknownType()
 {
     $f = fopen(MockTest::mockFile('anyFile'), 'r');
     fclose($f);
     $this->assertEquals('unknown type', Variable::formatVariableType($f));
 }