ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
43 
44  $ilDB = $DIC['ilDB'];
45 
46 
47  $this->enabled = ILIAS_LOG_ENABLED;
48  $this->level = ilLogLevel::INFO;
49  $this->cache_level = ilLogLevel::DEBUG;
50 
51  $this->storage = new ilSetting('logging');
52  $this->read();
53  }
54 
60  public static function getInstance()
61  {
62  if (self::$instance) {
63  return self::$instance;
64  }
65  return self::$instance = new self();
66  }
67 
74  public function getLevelByComponent($a_component_id)
75  {
76  include_once './Services/Logging/classes/class.ilLogComponentLevels.php';
77  $levels = ilLogComponentLevels::getInstance()->getLogComponents();
78  foreach ($levels as $level) {
79  if ($level->getComponentId() == $a_component_id) {
80  if ($level->getLevel()) {
81  return $level->getLevel();
82  }
83  }
84  }
85  return $this->getLevel();
86  }
87 
91  protected function getStorage()
92  {
93  return $this->storage;
94  }
95 
100  public function isEnabled()
101  {
102  return $this->enabled;
103  }
104 
105  public function getLogDir()
106  {
107  return ILIAS_LOG_DIR;
108  }
109 
110  public function getLogFile()
111  {
112  return ILIAS_LOG_FILE;
113  }
114 
119  public function getLevel()
120  {
121  return $this->level;
122  }
123 
128  public function setLevel($a_level)
129  {
130  $this->level = $a_level;
131  }
132 
137  public function setCacheLevel($a_level)
138  {
139  $this->cache_level = $a_level;
140  }
141 
146  public function getCacheLevel()
147  {
148  return $this->cache_level;
149  }
150 
155  public function enableCaching($a_status)
156  {
157  $this->cache = $a_status;
158  }
159 
160  public function isCacheEnabled()
161  {
162  return $this->cache;
163  }
164 
169  public function enableMemoryUsage($a_stat)
170  {
171  $this->memory_usage = $a_stat;
172  }
173 
178  public function isMemoryUsageEnabled()
179  {
180  return $this->memory_usage;
181  }
182 
187  public function isBrowserLogEnabled()
188  {
189  return $this->browser;
190  }
191 
192 
198  public function isBrowserLogEnabledForUser($a_login)
199  {
200  if (!$this->isBrowserLogEnabled()) {
201  return false;
202  }
203  if (in_array($a_login, $this->getBrowserLogUsers())) {
204  return true;
205  }
206  return false;
207  }
208 
213  public function enableBrowserLog($a_stat)
214  {
215  $this->browser = $a_stat;
216  }
217 
218  public function getBrowserLogUsers()
219  {
220  return $this->browser_users;
221  }
222 
223  public function setBrowserUsers(array $users)
224  {
225  $this->browser_users = $users;
226  }
227 
228 
232  public function update()
233  {
234  $this->getStorage()->set('level', $this->getLevel());
235  $this->getStorage()->set('cache', (int) $this->isCacheEnabled());
236  $this->getStorage()->set('cache_level', $this->getCacheLevel());
237  $this->getStorage()->set('memory_usage', $this->isMemoryUsageEnabled());
238  $this->getStorage()->set('browser', $this->isBrowserLogEnabled());
239  $this->getStorage()->set('browser_users', serialize($this->getBrowserLogUsers()));
240  }
241 
242 
248  private function read()
249  {
250  $this->setLevel($this->getStorage()->get('level', $this->level));
251  $this->enableCaching($this->getStorage()->get('cache', $this->cache));
252  $this->setCacheLevel($this->getStorage()->get('cache_level', $this->cache_level));
253  $this->enableMemoryUsage($this->getStorage()->get('memory_usage', $this->memory_usage));
254  $this->enableBrowserLog($this->getStorage()->get('browser', $this->browser));
255  $this->setBrowserUsers(unserialize($this->getStorage()->get('browser_users', serialize($this->browser_users))));
256  }
257 }
setCacheLevel($a_level)
Set cache level.
getLevelByComponent($a_component_id)
Get level by component.
global $DIC
Definition: saml.php:7
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.
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.