LogLevel.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2007 by Ivan Y. Khvostishkov                            *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 /* $Id: LogLevel.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     final class LogLevel extends Enumeration
00017     {
00018         const SEVERE    = 1; // highest value
00019         const WARNING   = 2;
00020         const INFO      = 3;
00021         const CONFIG    = 4;
00022         const FINE      = 5;
00023         const FINER     = 6;
00024         const FINEST    = 7; // lowest value
00025         
00026         protected $names = array(
00027             self::SEVERE    => 'severe',
00028             self::WARNING   => 'warning',
00029             self::INFO      => 'info',
00030             self::CONFIG    => 'config',
00031             self::FINE      => 'fine',
00032             self::FINER     => 'finer',
00033             self::FINEST    => 'finest'
00034         );
00035         
00039         public function setId($id)
00040         {
00041             Assert::isNull($this->id, 'i am immutable one!');
00042             
00043             return parent::setId($id);
00044         }
00045         
00049         public static function severe()
00050         {
00051             return self::getInstance(self::SEVERE);
00052         }
00053         
00057         public static function warning()
00058         {
00059             return self::getInstance(self::WARNING);
00060         }
00061         
00065         public static function info()
00066         {
00067             return self::getInstance(self::INFO);
00068         }
00069         
00073         public static function config()
00074         {
00075             return self::getInstance(self::CONFIG);
00076         }
00077         
00081         public static function fine()
00082         {
00083             return self::getInstance(self::FINE);
00084         }
00085         
00089         public static function finer()
00090         {
00091             return self::getInstance(self::FINER);
00092         }
00093         
00097         public static function finest()
00098         {
00099             return self::getInstance(self::FINEST);
00100         }
00101         
00105         private static function getInstance($id)
00106         {
00107             static $instances = array();
00108             
00109             if (!isset($instances[$id]))
00110                 $instances[$id] = new self($id);
00111             
00112             return $instances[$id];
00113         }
00114     }
00115 ?>

Generated on Sun Dec 9 21:56:24 2007 for onPHP by  doxygen 1.5.4