TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
FileWriter Class Reference
Inheritance diagram for FileWriter:
AbstractWriter WriterInterface

Public Member Functions

 __construct (array $options=array())
 
 __destruct ()
 
 setLogFile ($relativeLogFile)
 
 getLogFile ()
 
 writeLog (LogRecord $record)
 
- Public Member Functions inherited from AbstractWriter
 __construct (array $options=array())
 
- Public Member Functions inherited from WriterInterface
 writeLog (\TYPO3\CMS\Core\Log\LogRecord $record)
 

Protected Member Functions

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

Protected Attributes

 $logFile = ''
 
 $defaultLogFileTemplate = 'typo3temp/logs/typo3_%s.log'
 

Static Protected Attributes

static $logFileHandles = array()
 

Detailed Description

Log writer that writes the log records into a file.

Definition at line 26 of file FileWriter.php.

Constructor & Destructor Documentation

__construct ( array  $options = array())

Constructor, opens the log file handle

Parameters
array$options
Returns
FileWriter

Definition at line 59 of file FileWriter.php.

References FileWriter\getDefaultLogFileName(), and FileWriter\setLogFile().

__destruct ( )

Destructor, closes the log file handle

Definition at line 71 of file FileWriter.php.

References FileWriter\closeLogFile().

Member Function Documentation

closeLogFile ( )
protected

Closes the log file handle.

Returns
void

Definition at line 172 of file FileWriter.php.

Referenced by FileWriter\__destruct().

createHtaccessFile (   $htaccessFile)
protected

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

Parameters
string$htaccessFilePath of .htaccess file
Returns
void

Definition at line 207 of file FileWriter.php.

References $GLOBALS, and GeneralUtility\writeFile().

Referenced by FileWriter\createLogFile().

createLogFile ( )
protected

Creates the log file with correct permissions and parent directories, if needed

Returns
void

Definition at line 186 of file FileWriter.php.

References FileWriter\createHtaccessFile(), GeneralUtility\mkdir_deep(), and GeneralUtility\writeFile().

Referenced by FileWriter\openLogFile().

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 236 of file FileWriter.php.

References GeneralUtility\hmac().

Referenced by FileWriter\__construct().

getLogFile ( )

Gets the path to the log file.

Returns
string Path to the log file.

Definition at line 104 of file FileWriter.php.

References FileWriter\$logFile.

openLogFile ( )
protected

Opens the log file handle

Returns
void
Exceptions
\RuntimeExceptionif the log file can't be opened.

Definition at line 154 of file FileWriter.php.

References FileWriter\$logFile, and FileWriter\createLogFile().

Referenced by FileWriter\setLogFile().

setLogFile (   $relativeLogFile)

Sets the path to the log file.

Parameters
string$relativeLogFilepath to the log file, relative to PATH_site
Returns
WriterInterface
Exceptions
InvalidLogWriterConfigurationException

Definition at line 83 of file FileWriter.php.

References FileWriter\$logFile, GeneralUtility\getFileAbsFileName(), PathUtility\isAbsolutePath(), and FileWriter\openLogFile().

Referenced by FileWriter\__construct().

writeLog ( LogRecord  $record)

Writes the log record

Parameters
LogRecord$recordLog record
Returns
WriterInterface $this
Exceptions
\RuntimeException

Definition at line 116 of file FileWriter.php.

References LogRecord\getComponent(), LogRecord\getCreated(), LogRecord\getData(), LogRecord\getLevel(), LogRecord\getMessage(), LogLevel\getName(), and LogRecord\getRequestId().

Member Data Documentation

$defaultLogFileTemplate = 'typo3temp/logs/typo3_%s.log'
protected

Definition at line 40 of file FileWriter.php.

$logFile = ''
protected
$logFileHandles = array()
staticprotected

Definition at line 51 of file FileWriter.php.