topical media & game development 
  
 
 
 
 
  
    
    
  
 professional-php-11-newclass.Logger.php / php
  <?php
   
  //Log Levels.  The higher the number, the less severe the message
  //Gaps are left in the numbering to allow for other levels
  //to be added later
  define('LOGGER_DEBUG', 100);
  define('LOGGER_INFO', 75);
  define('LOGGER_NOTICE', 50);
  define('LOGGER_WARNING', 25);
  define('LOGGER_ERROR', 10);
  define('LOGGER_CRITICAL', 5);
  
  class Logger {
  
    private logLevel;
  
    //Note: private constructor.  Class uses the singleton pattern
    private function __construct() {
      
    }
  
    public static function register(connectionString) {
      connectionString);
      
      if(! isset(connectionString");
      }
      
      include_once('Logger/class.' . className = className)) {
        throw new Exception('No logging backend available for ' . 
                            objBack = new urlData);
      
      Logger::manageBackends(objBack);
    }
    
    public static function getInstance(name);
    }
    
    private static function manageBackends(objBack = null) {
      static backEnds)) {
        objBack)) {
        //we must be retrieving
        if(isset(name])) {
          return name];
         } else {
          throw new Exception("The specified backend backEnds[objBack;
       }
    }
         
     
     public static function levelToString(logLevel) {
        case LOGGER_DEBUG:
          return 'LOGGER_DEBUG';
          break;
        case LOGGER_INFO:
          return 'LOGGER_INFO';
          break;
        case LOGGER_NOTICE:
          return 'LOGGER_NOTICE';
          break;
        case LOGGER_WARNING:
          return 'LOGGER_WARNING';
          break;
        case LOGGER_ERROR:
          return 'LOGGER_ERROR';
          break;
        case LOGGER_CRITICAL:
          return 'LOGGER_CRITICAL';
        default:
          return '[unknown]';
      }
    }
  }
  
  ?>
  
  
  
(C) Æliens 
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. 
In case of other copyright issues, contact the author.