MediaSearch_Log
[ class tree: MediaSearch_Log ] [ index: MediaSearch_Log ] [ all elements ]

Source for file Abstract.php

Documentation is available at Abstract.php

  1. <?php
  2. /**
  3.  * MediaSearch
  4.  *
  5.  * LICENSE
  6.  *
  7.  * "THE BEER-WARE LICENSE" (Revision 42):
  8.  * "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
  9.  * As long as you retain this notice you can do whatever you want with
  10.  * this stuff. If we meet some day, and you think this stuff is worth it,
  11.  * you can buy me a beer in return.
  12.  *
  13.  * $Author$
  14.  * $Revision$
  15.  *
  16.  * @category    MediaSearch
  17.  * @package     MediaSearch_Log
  18.  * @copyright   Copyright (c) 2009 Sven Strittmatter
  19.  */
  20.  
  21. /**
  22.  * @see MediaSearch_Log_Interface
  23.  */
  24. require_once('MediaSearch/Log/Interface.php');
  25.  
  26. /**
  27.   * @todo Write apidoc.
  28.   *
  29.   * @abstract
  30.   * @category   MediaSearch
  31.   * @package    MediaSearch_Log
  32.   * @copyright  Copyright (c) 2009 Sven Strittmatter
  33.   */
  34. abstract class MediaSearch_Log_Abstract implements MediaSearch_Log_Interface {
  35.     const TRACE_LELVEL 46;
  36.  
  37.     private $logLevel;
  38.  
  39.     public function setLevel($integer 0{
  40.         $this->logLevel $integer;
  41.     }
  42.  
  43.     public function getLevel({
  44.         return $this->logLevel;
  45.     }
  46.  
  47.     public function info($message{
  48.         if (!$this->isEnabled(MediaSearch_Log::INFO)) {
  49.             return;
  50.         }
  51.  
  52.         $logLine  $this->getPreamble(MediaSearch_Log::INFO);
  53.         $logLine .= $message;
  54.         $this->log($logLine);
  55.     }
  56.  
  57.     public function trace($message$traceLevel 0{
  58.         if ($traceLevel 999999 || $traceLevel || !is_numeric($traceLevel)) {
  59.             $message  'Please use a integer value ';
  60.             $message .= 'from 0 up to 999999';
  61.             throw new RangeException($message);
  62.         }
  63.  
  64.         if (!$this->isEnabled(MediaSearch_Log::TRACE)) {
  65.             return;
  66.         }
  67.  
  68.         $logLine  $this->getPreamble(MediaSearch_Log::TRACE$traceLevel);
  69.         $logLine .= $message;
  70.         $this->log($logLine);
  71.     }
  72.  
  73.     public function debug($messagearray $variables null{
  74.         if (!$this->isEnabled(MediaSearch_Log::DEBUG)) {
  75.             return;
  76.         }
  77.  
  78.         $logLine  $this->getPreamble(MediaSearch_Log::DEBUG);
  79.         $logLine .= $message;
  80.         $this->log($logLine$variables);
  81.     }
  82.  
  83.     public function warn($message{
  84.         if (!$this->isEnabled(MediaSearch_Log::WARN)) {
  85.             return;
  86.         }
  87.  
  88.         $logLine  $this->getPreamble(MediaSearch_Log::WARN);
  89.         $logLine .= $message;
  90.         $this->log($logLine);
  91.     }
  92.  
  93.     public function error($message{
  94.         if (!$this->isEnabled(MediaSearch_Log::ERROR)) {
  95.             return;
  96.         }
  97.  
  98.         $logLine  $this->getPreamble(MediaSearch_Log::ERROR);
  99.         $logLine .= $message;
  100.         $this->log($logLine);
  101.     }
  102.  
  103.     public function fatal($message{
  104.         if (!$this->isEnabled(MediaSearch_Log::FATAL)) {
  105.             return;
  106.         }
  107.  
  108.         $logLine  $this->getPreamble(MediaSearch_Log::FATAL);
  109.         $logLine .= $message;
  110.         $this->log($logLine);
  111.     }
  112.  
  113.     abstract protected function log($messagearray $variables null);
  114.  
  115.     protected function isEnabled($logLevel{
  116.         return ($this->getLevel($logLevel=== $logLevel;
  117.     }
  118.  
  119.     protected function getPreamble($level$traceLevel nullreturn ''}
  120. }

Documentation generated on Mon, 17 Aug 2009 14:51:26 +0200 by phpDocumentor 1.4.2