1<?php 2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4/** 5 * individual log levels for components 6 * 7 * @author Stefan Meyer <smeyer.ilias@gmx.de> 8 * @version $Id$ 9 * 10 */ 11class ilLogComponentLevel 12{ 13 private $compontent_id = ''; 14 private $component_level = null; 15 16 public function __construct($a_component_id, $a_level = null) 17 { 18 $this->compontent_id = $a_component_id; 19 if ($a_level === null) { 20 $this->read(); 21 } else { 22 $this->setLevel($a_level); 23 } 24 } 25 26 public function getComponentId() 27 { 28 return $this->compontent_id; 29 } 30 31 public function setLevel($a_level) 32 { 33 $this->component_level = $a_level; 34 } 35 36 public function getLevel() 37 { 38 return $this->component_level; 39 } 40 41 public function update() 42 { 43 global $DIC; 44 45 $ilDB = $DIC['ilDB']; 46 47 ilLoggerFactory::getLogger('log')->debug('update called'); 48 49 $ilDB->replace( 50 'log_components', 51 array('component_id' => array('text',$this->getComponentId())), 52 array('log_level' => array('integer',$this->getLevel())) 53 ); 54 } 55 56 /** 57 * Read entry 58 * @global type $ilDB 59 */ 60 public function read() 61 { 62 global $DIC; 63 64 $ilDB = $DIC['ilDB']; 65 66 $query = 'SELECT * FROM log_components ' . 67 'WHERE component_id = ' . $ilDB->quote($this->getComponentId(), 'text'); 68 69 $res = $ilDB->query($query); 70 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) { 71 $this->component_level = $row->log_level; 72 } 73 } 74} 75