ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
62  return self::$instance;
63  }
64  return self::$instance = new self();
65  }
66 
73  public function getLevelByComponent($a_component_id)
74  {
75  include_once './Services/Logging/classes/class.ilLogComponentLevels.php';
76  $levels = ilLogComponentLevels::getInstance()->getLogComponents();
77  foreach($levels as $level)
78  {
79  if($level->getComponentId() == $a_component_id)
80  {
81  if($level->getLevel())
82  {
83  return $level->getLevel();
84  }
85  }
86  }
87  return $this->getLevel();
88  }
89 
93  protected function getStorage()
94  {
95  return $this->storage;
96  }
97 
102  public function isEnabled()
103  {
104  return $this->enabled;
105  }
106 
107  public function getLogDir()
108  {
109  return ILIAS_LOG_DIR;
110  }
111 
112  public function getLogFile()
113  {
114  return ILIAS_LOG_FILE;
115  }
116 
121  public function getLevel()
122  {
123  return $this->level;
124  }
125 
130  public function setLevel($a_level)
131  {
132  $this->level = $a_level;
133  }
134 
139  public function setCacheLevel($a_level)
140  {
141  $this->cache_level = $a_level;
142  }
143 
148  public function getCacheLevel()
149  {
150  return $this->cache_level;
151  }
152 
157  public function enableCaching($a_status)
158  {
159  $this->cache = $a_status;
160  }
161 
162  public function isCacheEnabled()
163  {
164  return $this->cache;
165  }
166 
171  public function enableMemoryUsage($a_stat)
172  {
173  $this->memory_usage = $a_stat;
174  }
175 
180  public function isMemoryUsageEnabled()
181  {
182  return $this->memory_usage;
183  }
184 
189  public function isBrowserLogEnabled()
190  {
191  return $this->browser;
192  }
193 
194 
200  public function isBrowserLogEnabledForUser($a_login)
201  {
202  if(!$this->isBrowserLogEnabled())
203  {
204  return FALSE;
205  }
206  if(in_array($a_login, $this->getBrowserLogUsers()))
207  {
208  return TRUE;
209  }
210  return FALSE;
211  }
212 
217  public function enableBrowserLog($a_stat)
218  {
219  $this->browser = $a_stat;
220  }
221 
222  public function getBrowserLogUsers()
223  {
224  return $this->browser_users;
225  }
226 
227  public function setBrowserUsers(array $users)
228  {
229  $this->browser_users = $users;
230  }
231 
232 
236  public function update()
237  {
238  $this->getStorage()->set('level', $this->getLevel());
239  $this->getStorage()->set('cache', (int) $this->isCacheEnabled());
240  $this->getStorage()->set('cache_level', $this->getCacheLevel());
241  $this->getStorage()->set('memory_usage', $this->isMemoryUsageEnabled());
242  $this->getStorage()->set('browser',$this->isBrowserLogEnabled());
243  $this->getStorage()->set('browser_users', serialize($this->getBrowserLogUsers()));
244  }
245 
246 
252  private function read()
253  {
254  $this->setLevel($this->getStorage()->get('level',$this->level));
255  $this->enableCaching($this->getStorage()->get('cache',$this->cache));
256  $this->setCacheLevel($this->getStorage()->get('cache_level',$this->cache_level));
257  $this->enableMemoryUsage($this->getStorage()->get('memory_usage', $this->memory_usage));
258  $this->enableBrowserLog($this->getStorage()->get('browser',$this->browser));
259  $this->setBrowserUsers(unserialize($this->getStorage()->get('browser_users', serialize($this->browser_users))));
260  }
261 }
262 ?>
setCacheLevel($a_level)
Set cache level.
ILIAS Setting Class.
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.
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.