ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilWACLog.php
Go to the documentation of this file.
1 <?php
2 require_once('./Services/Logging/classes/class.ilLog.php');
3 require_once('./Services/Init/classes/class.ilIniFile.php');
4 require_once('./Services/WebAccessChecker/classes/class.ilWACLogDummy.php');
5 
15 class ilWACLog extends ilLog {
16 
17  const WAC_LOG = 'wac.log';
21  protected $stack = array();
25  protected static $instances = array();
29  protected $pid = 0;
33  protected $is_dummy = false;
34 
35 
39  public static function getInstance() {
40  $key = getmypid();
42  $ilIliasIniFile = new ilIniFile('./ilias.ini.php');
43  $ilIliasIniFile->read();
45  $instance = new self($ilIliasIniFile->readVariable('log', 'path'), self::WAC_LOG, 'WAC');
46  } else {
47  $instance = new self($ilIliasIniFile->readVariable('log', 'path'), $ilIliasIniFile->readVariable('log', 'file'), 'WAC');
48  }
49  $instance->setPid($key);
50  self::$instances[$key] = $instance;
51  } else {
52  self::$instances[$key] = new ilWACLogDummy();
53  }
54 
55  return self::$instances[$key];
56  }
57 
58 
59  public function __destruct() {
60  if ($this->getStack()) {
61  global $ilUser;
62  parent::write('WebAccessChecker Request ' . str_repeat('#', 50));
63  parent::write('PID: ' . $this->getPid());
64  if (isset($_SERVER['HTTP_USER_AGENT'])) {
65  parent::write('User-Agent: ' . $_SERVER['HTTP_USER_AGENT']);
66  }
67  if (isset($_SERVER['HTTP_COOKIE'])) {
68  parent::write('Cookies: ' . $_SERVER['HTTP_COOKIE']);
69  }
70  if ($ilUser instanceof ilObjUser) {
71  parent::write('User_ID: ' . $ilUser->getId());
72  }
73  // parent::write('SERVER: ' . print_r($_SERVER, true));
74  foreach ($this->getStack() as $msg) {
75  parent::write($msg);
76  }
77  }
78  }
79 
80 
85  public function write($a_msg, $a_log_level = null) {
86  $this->stack[] = $a_msg;
87  }
88 
89 
93  public function getPid() {
94  return $this->pid;
95  }
96 
97 
101  public function setPid($pid) {
102  $this->pid = $pid;
103  }
104 
105 
109  public function getStack() {
110  return $this->stack;
111  }
112 
113 
117  public function setStack($stack) {
118  $this->stack = $stack;
119  }
120 }
121 
const WAC_LOG
Class ilWACLog.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
setStack($stack)
static getInstance()
logging
Definition: class.ilLog.php:18
Class ilWACLogDummy.
write($a_msg, $a_log_level=null)
global $ilIliasIniFile
global $ilUser
Definition: imgupload.php:15
INIFile Parser.
static $instances