ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
sspmod_core_Stats_Output_File Class Reference
+ Inheritance diagram for sspmod_core_Stats_Output_File:
+ Collaboration diagram for sspmod_core_Stats_Output_File:

Public Member Functions

 __construct (SimpleSAML_Configuration $config)
 Initialize the output. More...
 
 emit (array $data)
 Write a stats event. More...
 
 __construct (SimpleSAML_Configuration $config)
 Initialize the output. More...
 
 emit (array $data)
 Write a stats event. More...
 

Private Member Functions

 openLog ($date)
 Open a log file. More...
 

Private Attributes

 $logDir
 
 $file = NULL
 
 $fileDate = NULL
 

Detailed Description

Definition at line 8 of file File.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_core_Stats_Output_File::__construct ( SimpleSAML_Configuration  $config)

Initialize the output.

Parameters
SimpleSAML_Configuration$configThe configuration for this output.

Reimplemented from SimpleSAML_Stats_Output.

Definition at line 35 of file File.php.

35 {
36
37 $this->logDir = $config->getPathValue('directory');
38 if ($this->logDir === NULL) {
39 throw new Exception('Missing "directory" option for core:File');
40 }
41 if (!is_dir($this->logDir)) {
42 throw new Exception('Could not find log directory: ' . var_export($this->logDir, TRUE));
43 }
44
45 }
$config
Definition: bootstrap.php:15

References $config.

Member Function Documentation

◆ emit()

sspmod_core_Stats_Output_File::emit ( array  $data)

Write a stats event.

Parameters
array$dataThe event.

Reimplemented from SimpleSAML_Stats_Output.

Definition at line 79 of file File.php.

79 {
80 assert(isset($data['time']));
81
82 $time = $data['time'];
83 $milliseconds = (int)(($time - (int)$time) * 1000);
84
85 $timestamp = gmdate('Y-m-d\TH:i:s', $time) . sprintf('.%03dZ', $milliseconds);
86
87 $outDate = substr($timestamp, 0, 10); // The date-part of the timstamp
88
89 if ($outDate !== $this->fileDate) {
90 $this->openLog($outDate);
91 }
92
93 $line = $timestamp . ' ' . json_encode($data) . "\n";
94 fwrite($this->file, $line);
95 }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
openLog($date)
Open a log file.
Definition: File.php:53
$time
Definition: cron.php:21
$data
Definition: bench.php:6

References $data, $time, $timestamp, and openLog().

+ Here is the call graph for this function:

◆ openLog()

sspmod_core_Stats_Output_File::openLog (   $date)
private

Open a log file.

Parameters
string$dateThe date for the log file.

Definition at line 53 of file File.php.

53 {
54 assert(is_string($date));
55
56 if ($this->file !== NULL && $this->file !== FALSE) {
57 fclose($this->file);
58 $this->file = NULL;
59 }
60
61 $fileName = $this->logDir . '/' . $date . '.log';
62 $this->file = @fopen($fileName, 'a');
63 if ($this->file === FALSE) {
64 throw new SimpleSAML_Error_Exception('Error opening log file: ' . var_export($fileName, TRUE));
65 }
66
67 // Disable output buffering
68 stream_set_write_buffer($this->file, 0);
69
70 $this->fileDate = $date;
71 }

Referenced by emit().

+ Here is the caller graph for this function:

Field Documentation

◆ $file

sspmod_core_Stats_Output_File::$file = NULL
private

Definition at line 21 of file File.php.

◆ $fileDate

sspmod_core_Stats_Output_File::$fileDate = NULL
private

Definition at line 27 of file File.php.

◆ $logDir

sspmod_core_Stats_Output_File::$logDir
private

Definition at line 14 of file File.php.


The documentation for this class was generated from the following file: