Example #1
0
 /**
  * Adds a log entry to the database table.
  *
  * @param \Devlog\Devlog\Domain\Model\Entry $entry
  * @return boolean
  */
 public function add($entry)
 {
     $fields = array('run_id' => $entry->getRunId(), 'sorting' => $entry->getSorting(), 'severity' => $entry->getSeverity(), 'extkey' => $entry->getExtkey(), 'message' => $entry->getMessage(), 'location' => $entry->getLocation(), 'line' => $entry->getLine(), 'ip' => $entry->getIp(), 'cruser_id' => $entry->getCruserId(), 'crdate' => $entry->getCrdate(), 'pid' => $entry->getPid());
     // Handle extra data
     $fields['extra_data'] = gzcompress(serialize($entry->getExtraData()));
     $extraDataSize = strlen($fields['extra_data']);
     $maximumExtraDataSize = $this->extensionConfiguration['maximumExtraDataSize'];
     // If the entry's extra data is above the limit, replace it with a warning
     if (!empty($maximumExtraDataSize) && $extraDataSize > $maximumExtraDataSize) {
         $fields['extra_data'] = gzcompress(serialize('Extra data too large, not saved.'));
     }
     return $this->getDatabaseConnection()->exec_INSERTquery($this->databaseTable, $fields);
 }
Example #2
0
 /**
  * Writes the entry to the log file.
  *
  * @param \Devlog\Devlog\Domain\Model\Entry $entry
  * @return void
  */
 public function write($entry)
 {
     $logLine = '';
     $logLine .= date('c', $entry->getCrdate());
     switch ($entry->getSeverity()) {
         case 0:
             $severity = 'INFO';
             break;
         case 1:
             $severity = 'NOTICE';
             break;
         case 2:
             $severity = 'WARNING';
             break;
         case 3:
             $severity = 'ERROR';
             break;
         default:
             $severity = 'OK';
     }
     $logLine .= ' [' . $severity . ']';
     $logLine .= ' ' . $entry->getMessage();
     $logLine .= ' (' . $entry->getLocation() . ' ' . $entry->getLine() . ')';
     $logLine .= "\n";
     @fwrite($this->fileHandle, $logLine);
 }
Example #3
0
 /**
  * @test
  * @covers \Devlog\Devlog\Domain\Model\Entry::getMessage
  */
 public function getMessageReturnsInitialValueForString()
 {
     $this->assertSame('', $this->subject->getMessage());
 }