ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilWACLog.php
Go to the documentation of this file.
1<?php
2require_once('./Services/Logging/classes/class.ilLog.php');
3require_once('./Services/Init/classes/class.ilIniFile.php');
4require_once('./Services/WebAccessChecker/classes/class.ilWACLogDummy.php');
5require_once('./Services/WebAccessChecker/classes/class.ilWebAccessChecker.php');
6
16class ilWACLog extends ilLog {
17
18 const WAC_LOG = 'wac.log';
22 protected $stack = array();
26 protected static $instances = array();
30 protected $pid = 0;
34 protected $is_dummy = false;
35
36
40 public static function getInstance() {
41 $key = getmypid();
42 if (ilWebAccessChecker::isDEBUG() && defined('ILIAS_ABSOLUTE_PATH')) {
43 $ilIliasIniFile = new ilIniFile('./ilias.ini.php');
44 $ilIliasIniFile->read();
46 $instance = new self($ilIliasIniFile->readVariable('log', 'path'), self::WAC_LOG, 'WAC');
47 } else {
48 $instance = new self($ilIliasIniFile->readVariable('log', 'path'), $ilIliasIniFile->readVariable('log', 'file'), 'WAC');
49 }
50 $instance->setPid($key);
51 self::$instances[$key] = $instance;
52 } else {
53 self::$instances[$key] = new ilWACLogDummy();
54 }
55
56 return self::$instances[$key];
57 }
58
59
60 public function __destruct() {
61 if ($this->getStack()) {
62 global $ilUser;
63 parent::write('WebAccessChecker Request ' . str_repeat('#', 50));
64 parent::write('PID: ' . $this->getPid());
65 if (isset($_SERVER['HTTP_USER_AGENT'])) {
66 parent::write('User-Agent: ' . $_SERVER['HTTP_USER_AGENT']);
67 }
68 if (isset($_SERVER['HTTP_COOKIE'])) {
69 parent::write('Cookies: ' . $_SERVER['HTTP_COOKIE']);
70 }
71 if ($ilUser instanceof ilObjUser) {
72 parent::write('User_ID: ' . $ilUser->getId());
73 }
74 // parent::write('SERVER: ' . print_r($_SERVER, true));
75 foreach ($this->getStack() as $msg) {
76 parent::write($msg);
77 }
78 }
79 }
80
81
86 public function write($a_msg, $a_log_level = null) {
87 $this->stack[] = $a_msg;
88 }
89
90
94 public function getPid() {
95 return $this->pid;
96 }
97
98
102 public function setPid($pid) {
103 $this->pid = $pid;
104 }
105
106
110 public function getStack() {
111 return $this->stack;
112 }
113
114
118 public function setStack($stack) {
119 $this->stack = $stack;
120 }
121}
122
An exception for terminatinating execution or to throw for unit testing.
INIFile Parser.
logging
Definition: class.ilLog.php:19
Class ilWACLogDummy.
Class ilWACLog.
write($a_msg, $a_log_level=null)
setStack($stack)
const WAC_LOG
static getInstance()
static $instances
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$ilIliasIniFile
$ilUser
Definition: imgupload.php:18