ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLoggingErrorFileStorage Class Reference
+ 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 ()
 
 content ()
 
 pageHeader ()
 
 exceptionContent ()
 
 tablesContent ()
 
 tables ()
 

Protected Attributes

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

Private Member Functions

 stripNullBytes (string $ret)
 
 hideSensitiveData (array $super_global)
 
 shortenPHPSessionId (array $server)
 

Private Attributes

array $exclusion_list = []
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

36 {
37 $this->inspector = $inspector;
38 $this->file_path = $file_path;
39 $this->file_name = $file_name;
40 }

References $file_name, $file_path, and $inspector.

Member Function Documentation

◆ content()

ilLoggingErrorFileStorage::content ( )
protected

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

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 ( )
protected

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

57 : void
58 {
59 if (!is_dir($this->file_path)) {
60 ilFileUtils::makeDirParents($this->file_path);
61 }
62 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.

References ilFileUtils\makeDirParents().

Referenced by write().

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

◆ exceptionContent()

ilLoggingErrorFileStorage::exceptionContent ( )
protected

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

87 : string
88 {
89 $message = Formatter::formatExceptionPlain($this->inspector);
90
91 $exception = $this->inspector->getException();
92 $previous = $exception->getPrevious();
93 while ($previous) {
94 $message .= "\n\nCaused by\n" . sprintf(
95 '%s: %s in file %s on line %d',
96 get_class($previous),
97 $previous->getMessage(),
98 $previous->getFile(),
99 $previous->getLine()
100 );
101 $previous = $previous->getPrevious();
102 }
103
104 return $message;
105 }
$message
Definition: xapiexit.php:31

References $message.

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 162 of file class.ilLoggingErrorFileStorage.php.

162 : array
163 {
164 foreach ($this->exclusion_list as $parameter) {
165 if (isset($super_global[$parameter])) {
166 $super_global[$parameter] = 'REMOVED FOR SECURITY';
167 }
168
169 if (isset($super_global['post_vars'][$parameter])) {
170 $super_global['post_vars'][$parameter] = 'REMOVED FOR SECURITY';
171 }
172 }
173
174 return $super_global;
175 }

Referenced by tables().

+ Here is the caller graph for this function:

◆ pageHeader()

ilLoggingErrorFileStorage::pageHeader ( )
protected

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

82 : string
83 {
84 return '';
85 }

Referenced by content().

+ Here is the caller graph for this function:

◆ shortenPHPSessionId()

ilLoggingErrorFileStorage::shortenPHPSessionId ( array  $server)
private

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

177 : array
178 {
179 if (!isset($server['HTTP_COOKIE'])) {
180 return $server;
181 }
182 $cookie_content = $server['HTTP_COOKIE'];
183 $cookie_content = explode(';', $cookie_content);
184
185 foreach ($cookie_content as $key => $content) {
186 $content_array = explode('=', $content);
187 if (trim($content_array[0]) === session_name()) {
188 $content_array[1] = substr($content_array[1], 0, 5) . ' (SHORTENED FOR SECURITY)';
189 $cookie_content[$key] = implode('=', $content_array);
190 }
191 }
192
193 $server['HTTP_COOKIE'] = implode(';', $cookie_content);
194
195 return $server;
196 }
$server
Definition: shib_login.php:28

References $server.

Referenced by tables().

+ Here is the caller graph for this function:

◆ stripNullBytes()

ilLoggingErrorFileStorage::stripNullBytes ( string  $ret)
private

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

52 : string
53 {
54 return str_replace("\0", '', $ret);
55 }

Referenced by tablesContent().

+ Here is the caller graph for this function:

◆ tables()

ilLoggingErrorFileStorage::tables ( )
protected

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

138 : array
139 {
140 $post = $_POST;
142
143 $post = $this->hideSensitiveData($post);
146
147 return [
148 'GET Data' => $_GET,
149 'POST Data' => $post,
150 'Files' => $_FILES,
151 'Cookies' => $_COOKIE,
152 'Session' => $_SESSION ?? [],
153 'Server/Request Data' => $server,
154 'Environment Variables' => $_ENV
155 ];
156 }
$_GET['cmd']
Definition: lti.php:26
$_POST['cmd']
Definition: lti.php:27
$post
Definition: ltitoken.php:46
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$_COOKIE[session_name()]
Definition: xapitoken.php:54

References $_COOKIE, $_GET, $_POST, $_SERVER, $post, $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

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

107 : string
108 {
109 $ret = '';
110 foreach ($this->tables() as $title => $content) {
111 $ret .= "\n\n-- $title --\n\n";
112 if (count($content) > 0) {
113 foreach ($content as $key => $value) {
114 $key = str_pad((string) $key, self::KEY_SPACE);
115
116 // indent multiline values, first print_r, split in lines,
117 // indent all but first line, then implode again.
118 $first = true;
119 $indentation = str_pad('', self::KEY_SPACE);
120 $value = implode("\n", array_map(static function ($line) use (&$first, $indentation): string {
121 if ($first) {
122 $first = false;
123 return $line;
124 }
125 return $indentation . $line;
126 }, explode("\n", print_r($value, true))));
127
128 $ret .= "$key: $value\n";
129 }
130 } else {
131 $ret .= "empty\n";
132 }
133 }
134
135 return $this->stripNullBytes($ret);
136 }

References stripNullBytes(), 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 45 of file class.ilLoggingErrorFileStorage.php.

45 : self
46 {
47 $clone = clone $this;
48 $clone->exclusion_list = $exclusion_list;
49 return $clone;
50 }

References $exclusion_list.

◆ write()

ilLoggingErrorFileStorage::write ( )

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

71 : void
72 {
73 $this->createDir();
74
75 $file_name = $this->file_path . '/' . $this->file_name . self::FILE_FORMAT;
76 $stream = fopen($file_name, 'wb+');
77 fwrite($stream, $this->content());
78 fclose($stream);
79 chmod($file_name, 0755);
80 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $exclusion_list

array ilLoggingErrorFileStorage::$exclusion_list = []
private

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

Referenced by withExclusionList().

◆ $file_name

string ilLoggingErrorFileStorage::$file_name
protected

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

Referenced by __construct(), and write().

◆ $file_path

string ilLoggingErrorFileStorage::$file_path
protected

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

Referenced by __construct().

◆ $inspector

Inspector ilLoggingErrorFileStorage::$inspector
protected

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

Referenced by __construct().

◆ FILE_FORMAT

const ilLoggingErrorFileStorage::FILE_FORMAT = '.log'
protected

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

Referenced by write().

◆ KEY_SPACE

const ilLoggingErrorFileStorage::KEY_SPACE = 25
protected

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


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