Neos\Flow\Log\Backend\FileBackend::append PHP Метод

append() публичный Метод

Appends the given message along with the additional information into the log.
public append ( string $message, integer $severity = LOG_INFO, mixed $additionalData = null, string $packageKey = null, string $className = null, string $methodName = null ) : void
$message string The message to log
$severity integer One of the LOG_* constants
$additionalData mixed A variable containing more information about the event to be logged
$packageKey string Key of the package triggering the log (determined automatically if not specified)
$className string Name of the class triggering the log (determined automatically if not specified)
$methodName string Name of the method triggering the log (determined automatically if not specified)
Результат void
    public function append($message, $severity = LOG_INFO, $additionalData = null, $packageKey = null, $className = null, $methodName = null)
    {
        if ($severity > $this->severityThreshold) {
            return;
        }
        if (function_exists('posix_getpid')) {
            $processId = ' ' . str_pad(posix_getpid(), 10);
        } else {
            $processId = ' ';
        }
        $ipAddress = $this->logIpAddress === true ? str_pad(isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 15) : '';
        $severityLabel = isset($this->severityLabels[$severity]) ? $this->severityLabels[$severity] : 'UNKNOWN  ';
        $output = strftime('%y-%m-%d %H:%M:%S', time()) . $processId . ' ' . $ipAddress . $severityLabel . ' ' . str_pad($packageKey, 20) . ' ' . $message;
        if ($this->logMessageOrigin === true && ($className !== null || $methodName !== null)) {
            $output .= ' [logged in ' . $className . '::' . $methodName . '()]';
        }
        if (!empty($additionalData)) {
            $output .= PHP_EOL . $this->getFormattedVarDump($additionalData);
        }
        if ($this->fileHandle !== false) {
            fputs($this->fileHandle, $output . PHP_EOL);
        }
    }

Usage Example

 /**
  * @test
  */
 public function appendIgnoresMessagesAboveTheSeverityThreshold()
 {
     $logFileUrl = vfsStream::url('testDirectory') . '/test.log';
     $backend = new FileBackend(['logFileUrl' => $logFileUrl]);
     $backend->setSeverityThreshold(LOG_EMERG);
     $backend->open();
     $backend->append('foo', LOG_INFO);
     $this->assertSame(0, vfsStreamWrapper::getRoot()->getChild('test.log')->size());
 }