Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/alfresco/Service/Logger/Logger.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  * Copyright (C) 2005 Alfresco, Inc.
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019  * As a special exception to the terms and conditions of version 2.0 of 
00020  * the GPL, you may redistribute this Program in connection with Free/Libre 
00021  * and Open Source Software ("FLOSS") applications as described in Alfresco's 
00022  * FLOSS exception.  You should have recieved a copy of the text describing 
00023  * the FLOSS exception, and it is also available here: 
00024  * http://www.alfresco.com/legal/licensing"
00025  */
00026  
00027  require_once "LoggerConfig.php";
00028  
00029  class Logger
00030  {      
00031         private $componentName;
00032         
00033         public function __construct($componentName = null)
00034         {
00035                 $this->componentName = $componentName;
00036         }       
00037         
00038         public function isDebugEnabled()
00039         {
00040                 return $this->isEnabled(DEBUG);
00041         }
00042         
00043         public function debug($message)
00044         {
00045                 $this->write(DEBUG, $message);  
00046         }
00047         
00048         public function isWarningEnabled()
00049         {
00050                 return $this->isEnabled(WARNING);
00051         }
00052         
00053         public function warning($message)
00054         {
00055                 $this->write(WARNING, $message);        
00056         }
00057         
00058         public function isInformationEnabled()
00059         {
00060                 return $this->isEnabled(INFORMATION);           
00061         }
00062         
00063         public function information($message)
00064         {
00065                 $this->write(INFORMATION, $message);    
00066         }
00067         
00068         private function isEnabled($logLevel)
00069         {
00070                 global $componentLogLevels, $defaultLogLevel;
00071                 
00072                 $logLevels = $defaultLogLevel;
00073                 if ($this->componentName != null && isset($componentLogLevels[$this->componentName]) == true)
00074                 {
00075                         $logLevels = $componentLogLevels[$this->componentName];
00076                 }
00077                 
00078                 return in_array($logLevel, $logLevels);
00079         }
00080         
00081         private function write($logLevel, $message)
00082         {
00083                 global $logFile;
00084                 
00085                 $handle = fopen($logFile, "a");
00086                 fwrite($handle, $logLevel." ".date("G:i:s d/m/Y")." - ".$message."\r\n");
00087                 fclose($handle);
00088         }
00089  }
00090 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations