‪TYPO3CMS  10.4
TYPO3\CMS\Core\Log\Writer\FileWriter Class Reference
Inheritance diagram for TYPO3\CMS\Core\Log\Writer\FileWriter:
TYPO3\CMS\Core\Log\Writer\AbstractWriter TYPO3\CMS\Core\Log\Writer\WriterInterface

Public Member Functions

 __construct (array $options=[])
 
 __destruct ()
 
 setLogFileInfix (string $infix)
 
WriterInterface setLogFile ($relativeLogFile)
 
string getLogFile ()
 
WriterInterface writeLog (LogRecord $record)
 

Protected Member Functions

 openLogFile ()
 
 closeLogFile ()
 
 createLogFile ()
 
 createHtaccessFile ($htaccessFile)
 
string getDefaultLogFileName ()
 

Protected Attributes

string $logFile = ''
 
string $logFileInfix = ''
 
string $defaultLogFileTemplate = '/log/typo3_%s.log'
 

Static Protected Attributes

static array $logFileHandles = array( )
 
static array $logFileHandlesCount = array( )
 

Detailed Description

Log writer that writes the log records into a file.

Definition at line 27 of file FileWriter.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Log\Writer\FileWriter::__construct ( array  $options = [])

Constructor, opens the log file handle

Parameters
array$options

Reimplemented from TYPO3\CMS\Core\Log\Writer\AbstractWriter.

Definition at line 71 of file FileWriter.php.

References TYPO3\CMS\Core\Log\Writer\FileWriter\getDefaultLogFileName(), and TYPO3\CMS\Core\Log\Writer\FileWriter\setLogFile().

◆ __destruct()

TYPO3\CMS\Core\Log\Writer\FileWriter::__destruct ( )

Destructor, closes the log file handle

Definition at line 83 of file FileWriter.php.

References TYPO3\CMS\Core\Log\Writer\FileWriter\$logFile, and TYPO3\CMS\Core\Log\Writer\FileWriter\closeLogFile().

Member Function Documentation

◆ closeLogFile()

TYPO3\CMS\Core\Log\Writer\FileWriter::closeLogFile ( )
protected

Closes the log file handle.

Definition at line 197 of file FileWriter.php.

Referenced by TYPO3\CMS\Core\Log\Writer\FileWriter\__destruct().

◆ createHtaccessFile()

TYPO3\CMS\Core\Log\Writer\FileWriter::createHtaccessFile (   $htaccessFile)
protected

Creates .htaccess file inside a new directory to access protect it

Parameters
string$htaccessFile‪Path of .htaccess file

Definition at line 238 of file FileWriter.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\GeneralUtility\writeFile().

Referenced by TYPO3\CMS\Core\Log\Writer\FileWriter\createLogFile().

◆ createLogFile()

◆ getDefaultLogFileName()

string TYPO3\CMS\Core\Log\Writer\FileWriter::getDefaultLogFileName ( )
protected

Returns the path to the default log file. Uses the defaultLogFileTemplate and replaces the s placeholder with a short MD5 hash based on a static string and the current encryption key.

Returns
‪string

Definition at line 266 of file FileWriter.php.

References TYPO3\CMS\Core\Core\Environment\getVarPath().

Referenced by TYPO3\CMS\Core\Log\Writer\FileWriter\__construct().

◆ getLogFile()

string TYPO3\CMS\Core\Log\Writer\FileWriter::getLogFile ( )

Gets the path to the log file.

Returns
‪string Path to the log file.

Definition at line 127 of file FileWriter.php.

References TYPO3\CMS\Core\Log\Writer\FileWriter\$logFile.

◆ openLogFile()

TYPO3\CMS\Core\Log\Writer\FileWriter::openLogFile ( )
protected

◆ setLogFile()

WriterInterface TYPO3\CMS\Core\Log\Writer\FileWriter::setLogFile (   $relativeLogFile)

Sets the path to the log file.

Parameters
string$relativeLogFile‪path to the log file, relative to public web dir
Returns
WriterInterface
Exceptions
InvalidLogWriterConfigurationException

Definition at line 103 of file FileWriter.php.

References TYPO3\CMS\Core\Log\Writer\FileWriter\$logFile, TYPO3\CMS\Core\Utility\PathUtility\isAbsolutePath(), and TYPO3\CMS\Core\Log\Writer\FileWriter\openLogFile().

Referenced by TYPO3\CMS\Core\Log\Writer\FileWriter\__construct().

◆ setLogFileInfix()

TYPO3\CMS\Core\Log\Writer\FileWriter::setLogFileInfix ( string  $infix)

Definition at line 91 of file FileWriter.php.

◆ writeLog()

Member Data Documentation

◆ $defaultLogFileTemplate

string TYPO3\CMS\Core\Log\Writer\FileWriter::$defaultLogFileTemplate = '/log/typo3_%s.log'
protected

Default log file path

Definition at line 43 of file FileWriter.php.

◆ $logFile

string TYPO3\CMS\Core\Log\Writer\FileWriter::$logFile = ''
protected

◆ $logFileHandles

array TYPO3\CMS\Core\Log\Writer\FileWriter::$logFileHandles = array( )
staticprotected

Log file handle storage

To avoid concurrent file handles on a the same file when using several FileWriter instances, we share the file handles in a static class variable

Definition at line 53 of file FileWriter.php.

◆ $logFileHandlesCount

array TYPO3\CMS\Core\Log\Writer\FileWriter::$logFileHandlesCount = array( )
staticprotected

Keep track of used file handles by different fileWriter instances As the logger gets instantiated by class name but the resources are shared via the static $logFileHandles we need to track usage of file handles to avoid closing handles that are still needed by different instances. Only if the count is zero may the file handle be closed.

Definition at line 64 of file FileWriter.php.

◆ $logFileInfix

string TYPO3\CMS\Core\Log\Writer\FileWriter::$logFileInfix = ''
protected

Definition at line 37 of file FileWriter.php.