[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpexcel/PHPExcel/CalcEngine/ -> Logger.php (source)

   1  <?php
   2  
   3  /**
   4   * PHPExcel_CalcEngine_Logger
   5   *
   6   * Copyright (c) 2006 - 2015 PHPExcel
   7   *
   8   * This library is free software; you can redistribute it and/or
   9   * modify it under the terms of the GNU Lesser General Public
  10   * License as published by the Free Software Foundation; either
  11   * version 2.1 of the License, or (at your option) any later version.
  12   *
  13   * This library is distributed in the hope that it will be useful,
  14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16   * Lesser General Public License for more details.
  17   *
  18   * You should have received a copy of the GNU Lesser General Public
  19   * License along with this library; if not, write to the Free Software
  20   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  21   *
  22   * @category   PHPExcel
  23   * @package    PHPExcel_Calculation
  24   * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  25   * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  26   * @version    ##VERSION##, ##DATE##
  27   */
  28  class PHPExcel_CalcEngine_Logger
  29  {
  30      /**
  31       * Flag to determine whether a debug log should be generated by the calculation engine
  32       *        If true, then a debug log will be generated
  33       *        If false, then a debug log will not be generated
  34       *
  35       * @var boolean
  36       */
  37      private $writeDebugLog = false;
  38  
  39      /**
  40       * Flag to determine whether a debug log should be echoed by the calculation engine
  41       *        If true, then a debug log will be echoed
  42       *        If false, then a debug log will not be echoed
  43       * A debug log can only be echoed if it is generated
  44       *
  45       * @var boolean
  46       */
  47      private $echoDebugLog = false;
  48  
  49      /**
  50       * The debug log generated by the calculation engine
  51       *
  52       * @var string[]
  53       */
  54      private $debugLog = array();
  55  
  56      /**
  57       * The calculation engine cell reference stack
  58       *
  59       * @var PHPExcel_CalcEngine_CyclicReferenceStack
  60       */
  61      private $cellStack;
  62  
  63      /**
  64       * Instantiate a Calculation engine logger
  65       *
  66       * @param  PHPExcel_CalcEngine_CyclicReferenceStack $stack
  67       */
  68      public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack)
  69      {
  70          $this->cellStack = $stack;
  71      }
  72  
  73      /**
  74       * Enable/Disable Calculation engine logging
  75       *
  76       * @param  boolean $pValue
  77       */
  78      public function setWriteDebugLog($pValue = false)
  79      {
  80          $this->writeDebugLog = $pValue;
  81      }
  82  
  83      /**
  84       * Return whether calculation engine logging is enabled or disabled
  85       *
  86       * @return  boolean
  87       */
  88      public function getWriteDebugLog()
  89      {
  90          return $this->writeDebugLog;
  91      }
  92  
  93      /**
  94       * Enable/Disable echoing of debug log information
  95       *
  96       * @param  boolean $pValue
  97       */
  98      public function setEchoDebugLog($pValue = false)
  99      {
 100          $this->echoDebugLog = $pValue;
 101      }
 102  
 103      /**
 104       * Return whether echoing of debug log information is enabled or disabled
 105       *
 106       * @return  boolean
 107       */
 108      public function getEchoDebugLog()
 109      {
 110          return $this->echoDebugLog;
 111      }
 112  
 113      /**
 114       * Write an entry to the calculation engine debug log
 115       */
 116      public function writeDebugLog()
 117      {
 118          //    Only write the debug log if logging is enabled
 119          if ($this->writeDebugLog) {
 120              $message = implode(func_get_args());
 121              $cellReference = implode(' -> ', $this->cellStack->showStack());
 122              if ($this->echoDebugLog) {
 123                  echo $cellReference,
 124                      ($this->cellStack->count() > 0 ? ' => ' : ''),
 125                      $message,
 126                      PHP_EOL;
 127              }
 128              $this->debugLog[] = $cellReference .
 129                  ($this->cellStack->count() > 0 ? ' => ' : '') .
 130                  $message;
 131          }
 132      }
 133  
 134      /**
 135       * Clear the calculation engine debug log
 136       */
 137      public function clearLog()
 138      {
 139          $this->debugLog = array();
 140      }
 141  
 142      /**
 143       * Return the calculation engine debug log
 144       *
 145       * @return  string[]
 146       */
 147      public function getLog()
 148      {
 149          return $this->debugLog;
 150      }
 151  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1