ILIAS  release_7 Revision v7.30-3-g800a261c036
ilLoggingErrorFileStorage Class Reference

Saves error informations into file. More...

+ Collaboration diagram for ilLoggingErrorFileStorage:

Public Member Functions

 __construct ($inspector, $file_path, $file_name)
 
 withExclusionList (array $exclusion_list)
 
 write ()
 

Data Fields

const KEY_SPACE = 25
 
const FILE_FORMAT = ".log"
 

Protected Member Functions

 createDir ($path)
 
 content ()
 
 pageHeader ()
 Get the header for the page. More...
 
 exceptionContent ()
 Get a short info about the exception. More...
 
 tablesContent ()
 Get the header for the page. More...
 
 tables ()
 Get the tables that should be rendered. More...
 

Private Member Functions

 hideSensitiveData (array $super_global)
 
 shortenPHPSessionId (array $server)
 Shorts the php session id. More...
 

Private Attributes

 $exclusion_list = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLoggingErrorFileStorage::__construct (   $inspector,
  $file_path,
  $file_name 
)

Definition at line 20 of file class.ilLoggingErrorFileStorage.php.

21 {
22 $this->inspector = $inspector;
23 $this->file_path = $file_path;
24 $this->file_name = $file_name;
25 }

Member Function Documentation

◆ content()

ilLoggingErrorFileStorage::content ( )
protected

Definition at line 44 of file class.ilLoggingErrorFileStorage.php.

45 {
46 return $this->pageHeader()
47 . $this->exceptionContent()
48 . $this->tablesContent()
49 ;
50 }
pageHeader()
Get the header for the page.
exceptionContent()
Get a short info about the exception.
tablesContent()
Get the header for the page.

References exceptionContent(), pageHeader(), and tablesContent().

Referenced by write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDir()

ilLoggingErrorFileStorage::createDir (   $path)
protected

Definition at line 37 of file class.ilLoggingErrorFileStorage.php.

38 {
39 if (!is_dir($this->file_path)) {
40 ilUtil::makeDirParents($this->file_path);
41 }
42 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\makeDirParents().

Referenced by write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exceptionContent()

ilLoggingErrorFileStorage::exceptionContent ( )
protected

Get a short info about the exception.

Returns
string

Definition at line 78 of file class.ilLoggingErrorFileStorage.php.

79 {
80 return Formatter::formatExceptionPlain($this->inspector);
81 }

Referenced by content().

+ Here is the caller graph for this function:

◆ hideSensitiveData()

ilLoggingErrorFileStorage::hideSensitiveData ( array  $super_global)
private
Parameters
array<string,mixed>$super_global
Returns
array<string, mixed>

Definition at line 146 of file class.ilLoggingErrorFileStorage.php.

146 : array
147 {
148 foreach ($this->exclusion_list as $parameter) {
149 if (isset($super_global[$parameter])) {
150 $super_global[$parameter] = 'REMOVED FOR SECURITY';
151 }
152
153 if (isset($super_global['post_vars'][$parameter])) {
154 $super_global['post_vars'][$parameter] = 'REMOVED FOR SECURITY';
155 }
156 }
157
158 return $super_global;
159 }

Referenced by tables().

+ Here is the caller graph for this function:

◆ pageHeader()

ilLoggingErrorFileStorage::pageHeader ( )
protected

Get the header for the page.

Returns
string

Definition at line 68 of file class.ilLoggingErrorFileStorage.php.

69 {
70 return "";
71 }

Referenced by content().

+ Here is the caller graph for this function:

◆ shortenPHPSessionId()

ilLoggingErrorFileStorage::shortenPHPSessionId ( array  $server)
private

Shorts the php session id.

Parameters
array$server
Returns
array

Definition at line 168 of file class.ilLoggingErrorFileStorage.php.

169 {
170 $cookie_content = $server["HTTP_COOKIE"];
171 $cookie_content = explode(";", $cookie_content);
172
173 foreach ($cookie_content as $key => $content) {
174 $content_array = explode("=", $content);
175 if (trim($content_array[0]) == session_name()) {
176 $content_array[1] = substr($content_array[1], 0, 5) . " (SHORTENED FOR SECURITY)";
177 $cookie_content[$key] = implode("=", $content_array);
178 }
179 }
180
181 $server["HTTP_COOKIE"] = implode(";", $cookie_content);
182
183 return $server;
184 }
$server

References $server.

Referenced by tables().

+ Here is the caller graph for this function:

◆ tables()

ilLoggingErrorFileStorage::tables ( )
protected

Get the tables that should be rendered.

Returns
array $title => $table

Definition at line 123 of file class.ilLoggingErrorFileStorage.php.

124 {
125 $post = $_POST;
127
128 $post = $this->hideSensitiveData($post);
131
132 return array( "GET Data" => $_GET
133 , "POST Data" => $post
134 , "Files" => $_FILES
135 , "Cookies" => $_COOKIE
136 , "Session" => isset($_SESSION) ? $_SESSION : array()
137 , "Server/Request Data" => $server
138 , "Environment Variables" => $_ENV
139 );
140 }
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
shortenPHPSessionId(array $server)
Shorts the php session id.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$_COOKIE[session_name()]
Definition: xapitoken.php:37

References $_COOKIE, $_GET, $_POST, $_SERVER, $_SESSION, $server, hideSensitiveData(), and shortenPHPSessionId().

Referenced by tablesContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tablesContent()

ilLoggingErrorFileStorage::tablesContent ( )
protected

Get the header for the page.

Returns
string

Definition at line 88 of file class.ilLoggingErrorFileStorage.php.

89 {
90 $ret = "";
91 foreach ($this->tables() as $title => $content) {
92 $ret .= "\n\n-- $title --\n\n";
93 if (count($content) > 0) {
94 foreach ($content as $key => $value) {
95 $key = str_pad($key, self::KEY_SPACE);
96
97 // indent multiline values, first print_r, split in lines,
98 // indent all but first line, then implode again.
99 $first = true;
100 $indentation = str_pad("", self::KEY_SPACE);
101 $value = implode("\n", array_map(function ($line) use (&$first, $indentation) {
102 if ($first) {
103 $first = false;
104 return $line;
105 }
106 return $indentation . $line;
107 }, explode("\n", print_r($value, true))));
108
109 $ret .= "$key: $value\n";
110 }
111 } else {
112 $ret .= "empty\n";
113 }
114 }
115 return $ret;
116 }
tables()
Get the tables that should be rendered.
$ret
Definition: parser.php:6

References $ret, and tables().

Referenced by content().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withExclusionList()

ilLoggingErrorFileStorage::withExclusionList ( array  $exclusion_list)
Parameters
list<string>$exclusion_list

Definition at line 30 of file class.ilLoggingErrorFileStorage.php.

30 : self
31 {
32 $clone = clone $this;
33 $clone->exclusion_list = $exclusion_list;
34 return $clone;
35 }

References $exclusion_list.

◆ write()

ilLoggingErrorFileStorage::write ( )

Definition at line 52 of file class.ilLoggingErrorFileStorage.php.

53 {
54 $this->createDir($this->file_path);
55
56 $file_name = $this->file_path . "/" . $this->file_name . self::FILE_FORMAT;
57 $stream = fopen($file_name, 'w+');
58 fwrite($stream, $this->content());
59 fclose($stream);
60 chmod($file_name, 0755);
61 }

References content(), createDir(), and FILE_FORMAT.

+ Here is the call graph for this function:

Field Documentation

◆ $exclusion_list

ilLoggingErrorFileStorage::$exclusion_list = []
private

Definition at line 18 of file class.ilLoggingErrorFileStorage.php.

Referenced by withExclusionList().

◆ FILE_FORMAT

const ilLoggingErrorFileStorage::FILE_FORMAT = ".log"

Definition at line 15 of file class.ilLoggingErrorFileStorage.php.

Referenced by write().

◆ KEY_SPACE

const ilLoggingErrorFileStorage::KEY_SPACE = 25

Definition at line 14 of file class.ilLoggingErrorFileStorage.php.


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