ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLoggingErrorFileStorage Class Reference

Saves error informations into file. More...

+ Collaboration diagram for ilLoggingErrorFileStorage:

Public Member Functions

 __construct ($inspector, $file_path, $file_name)
 
 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

 hidePassword (array $post)
 Replace passwort from post array with security message. More...
 
 shortenPHPSessionId (array $server)
 Shorts the php session id. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

18 {
19 $this->inspector = $inspector;
20 $this->file_path = $file_path;
21 $this->file_name = $file_name;
22 }

Member Function Documentation

◆ content()

ilLoggingErrorFileStorage::content ( )
protected

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

32 {
33 return $this->pageHeader()
34 . $this->exceptionContent()
35 . $this->tablesContent()
36 ;
37 }
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 24 of file class.ilLoggingErrorFileStorage.php.

25 {
26 if (!is_dir($this->file_path)) {
27 ilUtil::makeDirParents($this->file_path);
28 }
29 }
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 65 of file class.ilLoggingErrorFileStorage.php.

66 {
67 return Formatter::formatExceptionPlain($this->inspector);
68 }

Referenced by content().

+ Here is the caller graph for this function:

◆ hidePassword()

ilLoggingErrorFileStorage::hidePassword ( array  $post)
private

Replace passwort from post array with security message.

Parameters
array$post
Returns
array

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

136 {
137 if (isset($post["password"])) {
138 $post["password"] = "REMOVED FOR SECURITY";
139 }
140
141 return $post;
142 }
$post
Definition: post.php:34

References $post.

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

56 {
57 return "";
58 }

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

152 {
153 $cookie_content = $server["HTTP_COOKIE"];
154 $cookie_content = explode(";", $cookie_content);
155
156 foreach ($cookie_content as $key => $content) {
157 $content_array = explode("=", $content);
158 if (trim($content_array[0]) == session_name()) {
159 $content_array[1] = substr($content_array[1], 0, 5) . " (SHORTENED FOR SECURITY)";
160 $cookie_content[$key] = implode("=", $content_array);
161 }
162 }
163
164 $server["HTTP_COOKIE"] = implode(";", $cookie_content);
165
166 return $server;
167 }
$key
Definition: croninfo.php:18
$server
Definition: sabredav.php:48

References $key, and $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 110 of file class.ilLoggingErrorFileStorage.php.

111 {
112 $post = $_POST;
114
115 $post = $this->hidePassword($post);
117
118 return array( "GET Data" => $_GET
119 , "POST Data" => $post
120 , "Files" => $_FILES
121 , "Cookies" => $_COOKIE
122 , "Session" => isset($_SESSION) ? $_SESSION : array()
123 , "Server/Request Data" => $server
124 , "Environment Variables" => $_ENV
125 );
126 }
$_COOKIE['client_id']
Definition: server.php:9
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
hidePassword(array $post)
Replace passwort from post array with security message.
shortenPHPSessionId(array $server)
Shorts the php session id.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_COOKIE, $_GET, $_POST, $_SERVER, $_SESSION, $post, $server, hidePassword(), 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 75 of file class.ilLoggingErrorFileStorage.php.

76 {
77 $ret = "";
78 foreach ($this->tables() as $title => $content) {
79 $ret .= "\n\n-- $title --\n\n";
80 if (count($content) > 0) {
81 foreach ($content as $key => $value) {
82 $key = str_pad($key, self::KEY_SPACE);
83
84 // indent multiline values, first print_r, split in lines,
85 // indent all but first line, then implode again.
86 $first = true;
87 $indentation = str_pad("", self::KEY_SPACE);
88 $value = implode("\n", array_map(function ($line) use (&$first, $indentation) {
89 if ($first) {
90 $first = false;
91 return $line;
92 }
93 return $indentation . $line;
94 }, explode("\n", print_r($value, true))));
95
96 $ret .= "$key: $value\n";
97 }
98 } else {
99 $ret .= "empty\n";
100 }
101 }
102 return $ret;
103 }
tables()
Get the tables that should be rendered.
$ret
Definition: parser.php:6

References $key, $ret, $title, and tables().

Referenced by content().

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

◆ write()

ilLoggingErrorFileStorage::write ( )

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

40 {
41 $this->createDir($this->file_path);
42
43 $file_name = $this->file_path . "/" . $this->file_name . self::FILE_FORMAT;
44 $stream = fopen($file_name, 'w+');
45 fwrite($stream, $this->content());
46 fclose($stream);
47 chmod($file_name, 0755);
48 }
$stream
PHP stream implementation.

References GuzzleHttp\Psr7\$stream, content(), createDir(), and FILE_FORMAT.

+ Here is the call graph for this function:

Field Documentation

◆ 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: