ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLoggingDBSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Logging/classes/public/class.ilLogLevel.php';
5 include_once './Services/Administration/classes/class.ilSetting.php';
6 include_once './Services/Logging/interfaces/interface.ilLoggingSettings.php';
7 
8 
19 {
20  protected static $instance = null;
21 
22  private $enabled = false;
23 
24  private $storage = null;
25 
26  private $level = null;
27  private $cache = false;
28  private $cache_level = null;
29  private $memory_usage = false;
30  private $browser = false;
31  private $browser_users = array();
32 
33 
34 
40  private function __construct()
41  {
42  global $ilDB;
43 
44 
45  $this->enabled = ILIAS_LOG_ENABLED;
46  $this->level = ilLogLevel::INFO;
47  $this->cache_level = ilLogLevel::DEBUG;
48 
49  $this->storage = new ilSetting('logging');
50  $this->read();
51  }
52 
58  public static function getInstance()
59  {
60  if (self::$instance) {
61  return self::$instance;
62  }
63  return self::$instance = new self();
64  }
65 
72  public function getLevelByComponent($a_component_id)
73  {
74  include_once './Services/Logging/classes/class.ilLogComponentLevels.php';
75  $levels = ilLogComponentLevels::getInstance()->getLogComponents();
76  foreach ($levels as $level) {
77  if ($level->getComponentId() == $a_component_id) {
78  if ($level->getLevel()) {
79  return $level->getLevel();
80  }
81  }
82  }
83  return $this->getLevel();
84  }
85 
89  protected function getStorage()
90  {
91  return $this->storage;
92  }
93 
98  public function isEnabled()
99  {
100  return $this->enabled;
101  }
102 
103  public function getLogDir()
104  {
105  return ILIAS_LOG_DIR;
106  }
107 
108  public function getLogFile()
109  {
110  return ILIAS_LOG_FILE;
111  }
112 
117  public function getLevel()
118  {
119  return $this->level;
120  }
121 
126  public function setLevel($a_level)
127  {
128  $this->level = $a_level;
129  }
130 
135  public function setCacheLevel($a_level)
136  {
137  $this->cache_level = $a_level;
138  }
139 
144  public function getCacheLevel()
145  {
146  return $this->cache_level;
147  }
148 
153  public function enableCaching($a_status)
154  {
155  $this->cache = $a_status;
156  }
157 
158  public function isCacheEnabled()
159  {
160  return $this->cache;
161  }
162 
167  public function enableMemoryUsage($a_stat)
168  {
169  $this->memory_usage = $a_stat;
170  }
171 
176  public function isMemoryUsageEnabled()
177  {
178  return $this->memory_usage;
179  }
180 
185  public function isBrowserLogEnabled()
186  {
187  return $this->browser;
188  }
189 
190 
196  public function isBrowserLogEnabledForUser($a_login)
197  {
198  if (!$this->isBrowserLogEnabled()) {
199  return false;
200  }
201  if (in_array($a_login, $this->getBrowserLogUsers())) {
202  return true;
203  }
204  return false;
205  }
206 
211  public function enableBrowserLog($a_stat)
212  {
213  $this->browser = $a_stat;
214  }
215 
216  public function getBrowserLogUsers()
217  {
218  return $this->browser_users;
219  }
220 
221  public function setBrowserUsers(array $users)
222  {
223  $this->browser_users = $users;
224  }
225 
226 
230  public function update()
231  {
232  $this->getStorage()->set('level', $this->getLevel());
233  $this->getStorage()->set('cache', (int) $this->isCacheEnabled());
234  $this->getStorage()->set('cache_level', $this->getCacheLevel());
235  $this->getStorage()->set('memory_usage', $this->isMemoryUsageEnabled());
236  $this->getStorage()->set('browser', $this->isBrowserLogEnabled());
237  $this->getStorage()->set('browser_users', serialize($this->getBrowserLogUsers()));
238  }
239 
240 
246  private function read()
247  {
248  $this->setLevel($this->getStorage()->get('level', $this->level));
249  $this->enableCaching($this->getStorage()->get('cache', $this->cache));
250  $this->setCacheLevel($this->getStorage()->get('cache_level', $this->cache_level));
251  $this->enableMemoryUsage($this->getStorage()->get('memory_usage', $this->memory_usage));
252  $this->enableBrowserLog($this->getStorage()->get('browser', $this->browser));
253  $this->setBrowserUsers(unserialize($this->getStorage()->get('browser_users', serialize($this->browser_users))));
254  }
255 }
setCacheLevel($a_level)
Set cache level.
getLevelByComponent($a_component_id)
Get level by component.
isMemoryUsageEnabled()
Check if loggin of memory usage is enabled.
setLevel($a_level)
Set log level.
isBrowserLogEnabled()
Check if browser log is enabled.
enableMemoryUsage($a_stat)
Enable logging of memory usage.
Create styles array
The data for the language used.
static getInstance()
Get instance.
$users
Definition: authpage.php:44
enableCaching($a_status)
Enable caching.
enableBrowserLog($a_stat)
Enable browser log.
global $ilDB
isBrowserLogEnabledForUser($a_login)
Check if browser log is enabled for user.
__construct()
Singleton contructor.
isEnabled()
Check if logging is enabled.
getCacheLevel()
Get cache level.