Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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