Subversion Repositories phpLibraryV2

Rev

Rev 8 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

<?php

   require_once 'LogFile.class.php';
   
   class DebugFile extends LogFile {
      
      public $logLevel = 5; // logging level
      
      public function __constructor( $filename = null, $logLevel = null, $maxSize = null ) {
         // session variables can create defaults
         if ( isset( $_SESSION['DEBUG']['level'] ) && $logLevel === null ) {
            $this->logLevel = $_SESSION['DEBUG']['level'];
         } else {
            $this->logLevel = $logLevel;
         }
         if (  isset( $_SESSION['DEBUG']['File Name'] ) 
               && ( $filename === null  || strlen( $filename ) == 0 )
            ) {
            $filename = $_SESSION['DEBUG']['File Name'];
         }
         parent::_constructor( $filename, null, $maxSize, null );
      }
      
      public function writeLog( $logLevel, $message, $file = null, $class = null, $function = null, $line = null ) {
         if ( $logLevel <= $this->logLevel ) {
            $extra = array();
            if ( isset( $file ) ) $extra[] = "File: $file";
            if ( isset( $class ) ) $extra[] = "Class: $class";
            if ( isset( $function ) ) $extra[] = "Function: $function";
            if ( isset( $line ) ) $extra[] = "Line: $line";
            $message = implode( ',', $extra ) . $message;
            return parent::writeLog( $message );
         } else {
            return true;
         }
      } // writeLog
   } // class logging
   
?>