ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLoggingErrorFileStorage Class Reference

Saves error informations into file. More...

+ Collaboration diagram for ilLoggingErrorFileStorage:

Public Member Functions

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

Protected Member Functions

 createDir (string $path)
 
 content ()
 
 pageHeader ()
 
 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...
 

Protected Attributes

const KEY_SPACE = 25
 
const FILE_FORMAT = ".log"
 
Inspector $inspector
 
string $file_path
 
string $file_name
 

Private Member Functions

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

Private Attributes

array $exclusion_list = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $file_name, $file_path, and $inspector.

39  {
40  $this->inspector = $inspector;
41  $this->file_path = $file_path;
42  $this->file_name = $file_name;
43  }

Member Function Documentation

◆ content()

ilLoggingErrorFileStorage::content ( )
protected

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

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

Referenced by write().

62  : string
63  {
64  return $this->pageHeader()
65  . $this->exceptionContent()
66  . $this->tablesContent()
67  ;
68  }
tablesContent()
Get the header for the page.
exceptionContent()
Get a short info about the exception.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDir()

ilLoggingErrorFileStorage::createDir ( string  $path)
protected

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

References ilFileUtils\makeDirParents().

Referenced by write().

55  : void
56  {
57  if (!is_dir($this->file_path)) {
58  ilFileUtils::makeDirParents($this->file_path);
59  }
60  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ 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.

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

Referenced by content().

89  : string
90  {
91  return Formatter::formatExceptionPlain($this->inspector);
92  }
+ 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 153 of file class.ilLoggingErrorFileStorage.php.

Referenced by tables().

153  : array
154  {
155  foreach ($this->exclusion_list as $parameter) {
156  if (isset($super_global[$parameter])) {
157  $super_global[$parameter] = 'REMOVED FOR SECURITY';
158  }
159 
160  if (isset($super_global['post_vars'][$parameter])) {
161  $super_global['post_vars'][$parameter] = 'REMOVED FOR SECURITY';
162  }
163  }
164 
165  return $super_global;
166  }
+ Here is the caller graph for this function:

◆ pageHeader()

ilLoggingErrorFileStorage::pageHeader ( )
protected

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

Referenced by content().

81  : string
82  {
83  return "";
84  }
+ Here is the caller graph for this function:

◆ shortenPHPSessionId()

ilLoggingErrorFileStorage::shortenPHPSessionId ( array  $server)
private

Shorts the php session id.

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

References ILIAS\LTI\ToolProvider\$key, and $server.

Referenced by tables().

171  : array
172  {
173  if (!isset($server["HTTP_COOKIE"])) {
174  return $server;
175  }
176  $cookie_content = $server["HTTP_COOKIE"];
177  $cookie_content = explode(";", $cookie_content);
178 
179  foreach ($cookie_content as $key => $content) {
180  $content_array = explode("=", $content);
181  if (trim($content_array[0]) == session_name()) {
182  $content_array[1] = substr($content_array[1], 0, 5) . " (SHORTENED FOR SECURITY)";
183  $cookie_content[$key] = implode("=", $content_array);
184  }
185  }
186 
187  $server["HTTP_COOKIE"] = implode(";", $cookie_content);
188 
189  return $server;
190  }
string $key
Consumer key/client ID value.
Definition: System.php:193
$server
+ Here is the caller graph for this function:

◆ tables()

ilLoggingErrorFileStorage::tables ( )
protected

Get the tables that should be rendered.

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

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

Referenced by tablesContent().

130  : array
131  {
132  $post = $_POST;
133  $server = $_SERVER;
134 
135  $post = $this->hideSensitiveData($post);
138 
139  return array( "GET Data" => $_GET
140  , "POST Data" => $post
141  , "Files" => $_FILES
142  , "Cookies" => $_COOKIE
143  , "Session" => $_SESSION ?? array()
144  , "Server/Request Data" => $server
145  , "Environment Variables" => $_ENV
146  );
147  }
shortenPHPSessionId(array $server)
Shorts the php session id.
$_GET['client_id']
Definition: saml1-acs.php:21
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$server
$_COOKIE[session_name()]
Definition: xapitoken.php:54
$post
Definition: ltitoken.php:49
+ 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.

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

References ILIAS\LTI\ToolProvider\$key, and tables().

Referenced by content().

97  : string
98  {
99  $ret = "";
100  foreach ($this->tables() as $title => $content) {
101  $ret .= "\n\n-- $title --\n\n";
102  if (count($content) > 0) {
103  foreach ($content as $key => $value) {
104  $key = str_pad((string) $key, self::KEY_SPACE);
105 
106  // indent multiline values, first print_r, split in lines,
107  // indent all but first line, then implode again.
108  $first = true;
109  $indentation = str_pad("", self::KEY_SPACE);
110  $value = implode("\n", array_map(function ($line) use (&$first, $indentation) {
111  if ($first) {
112  $first = false;
113  return $line;
114  }
115  return $indentation . $line;
116  }, explode("\n", print_r($value, true))));
117 
118  $ret .= "$key: $value\n";
119  }
120  } else {
121  $ret .= "empty\n";
122  }
123  }
124  return $ret;
125  }
string $key
Consumer key/client ID value.
Definition: System.php:193
tables()
Get the tables that should be rendered.
+ 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 48 of file class.ilLoggingErrorFileStorage.php.

References $exclusion_list.

Referenced by ilErrorHandling\defaultHandler().

48  : self
49  {
50  $clone = clone $this;
51  $clone->exclusion_list = $exclusion_list;
52  return $clone;
53  }
+ Here is the caller graph for this function:

◆ write()

ilLoggingErrorFileStorage::write ( )

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

References content(), and createDir().

Referenced by ilErrorHandling\defaultHandler().

70  : void
71  {
72  $this->createDir($this->file_path);
73 
74  $file_name = $this->file_path . "/" . $this->file_name . self::FILE_FORMAT;
75  $stream = fopen($file_name, 'w+');
76  fwrite($stream, $this->content());
77  fclose($stream);
78  chmod($file_name, 0755);
79  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $exclusion_list

array ilLoggingErrorFileStorage::$exclusion_list = []
private

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

Referenced by withExclusionList().

◆ $file_name

string ilLoggingErrorFileStorage::$file_name
protected

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

Referenced by __construct().

◆ $file_path

string ilLoggingErrorFileStorage::$file_path
protected

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

Referenced by __construct().

◆ $inspector

Inspector ilLoggingErrorFileStorage::$inspector
protected

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

Referenced by __construct().

◆ FILE_FORMAT

const ilLoggingErrorFileStorage::FILE_FORMAT = ".log"
protected

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

◆ KEY_SPACE

const ilLoggingErrorFileStorage::KEY_SPACE = 25
protected

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


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