[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Copyright (C) 2005-2010 Alfresco Software Limited. 4 * 5 * This file is part of Alfresco 6 * 7 * Alfresco is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * Alfresco is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 require_once $CFG->libdir."/alfresco/Service/Logger/LoggerConfig.php"; 22 23 class Logger 24 { 25 private $componentName; 26 27 public function __construct($componentName = null) 28 { 29 $this->componentName = $componentName; 30 } 31 32 public function isDebugEnabled() 33 { 34 return $this->isEnabled(DEBUG); 35 } 36 37 public function debug($message) 38 { 39 $this->write(DEBUG, $message); 40 } 41 42 public function isWarningEnabled() 43 { 44 return $this->isEnabled(WARNING); 45 } 46 47 public function warning($message) 48 { 49 $this->write(WARNING, $message); 50 } 51 52 public function isInformationEnabled() 53 { 54 return $this->isEnabled(INFORMATION); 55 } 56 57 public function information($message) 58 { 59 $this->write(INFORMATION, $message); 60 } 61 62 private function isEnabled($logLevel) 63 { 64 global $componentLogLevels, $defaultLogLevel; 65 66 $logLevels = $defaultLogLevel; 67 if ($this->componentName != null && isset($componentLogLevels[$this->componentName]) == true) 68 { 69 $logLevels = $componentLogLevels[$this->componentName]; 70 } 71 72 return in_array($logLevel, $logLevels); 73 } 74 75 private function write($logLevel, $message) 76 { 77 global $logFile; 78 79 $handle = fopen($logFile, "a"); 80 fwrite($handle, $logLevel." ".date("G:i:s d/m/Y")." - ".$message."\r\n"); 81 fclose($handle); 82 } 83 } 84 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |