visualizer
/
vendor
/
phpoffice
/
phpspreadsheet
/
src
/
PhpSpreadsheet
/
Calculation
/
Engine
/
Logger.php
Logger.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.7.1, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/Logger.php
| 1 | <?php |
| 2 | |
| 3 | namespace PhpOffice\PhpSpreadsheet\Calculation\Engine; |
| 4 | |
| 5 | class Logger |
| 6 | { |
| 7 | /** |
| 8 | * Flag to determine whether a debug log should be generated by the calculation engine |
| 9 | * If true, then a debug log will be generated |
| 10 | * If false, then a debug log will not be generated. |
| 11 | * |
| 12 | * @var bool |
| 13 | */ |
| 14 | private $writeDebugLog = false; |
| 15 | |
| 16 | /** |
| 17 | * Flag to determine whether a debug log should be echoed by the calculation engine |
| 18 | * If true, then a debug log will be echoed |
| 19 | * If false, then a debug log will not be echoed |
| 20 | * A debug log can only be echoed if it is generated. |
| 21 | * |
| 22 | * @var bool |
| 23 | */ |
| 24 | private $echoDebugLog = false; |
| 25 | |
| 26 | /** |
| 27 | * The debug log generated by the calculation engine. |
| 28 | * |
| 29 | * @var string[] |
| 30 | */ |
| 31 | private $debugLog = []; |
| 32 | |
| 33 | /** |
| 34 | * The calculation engine cell reference stack. |
| 35 | * |
| 36 | * @var CyclicReferenceStack |
| 37 | */ |
| 38 | private $cellStack; |
| 39 | |
| 40 | /** |
| 41 | * Instantiate a Calculation engine logger. |
| 42 | * |
| 43 | * @param CyclicReferenceStack $stack |
| 44 | */ |
| 45 | public function __construct(CyclicReferenceStack $stack) |
| 46 | { |
| 47 | $this->cellStack = $stack; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Enable/Disable Calculation engine logging. |
| 52 | * |
| 53 | * @param bool $pValue |
| 54 | */ |
| 55 | public function setWriteDebugLog($pValue) |
| 56 | { |
| 57 | $this->writeDebugLog = $pValue; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Return whether calculation engine logging is enabled or disabled. |
| 62 | * |
| 63 | * @return bool |
| 64 | */ |
| 65 | public function getWriteDebugLog() |
| 66 | { |
| 67 | return $this->writeDebugLog; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Enable/Disable echoing of debug log information. |
| 72 | * |
| 73 | * @param bool $pValue |
| 74 | */ |
| 75 | public function setEchoDebugLog($pValue) |
| 76 | { |
| 77 | $this->echoDebugLog = $pValue; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Return whether echoing of debug log information is enabled or disabled. |
| 82 | * |
| 83 | * @return bool |
| 84 | */ |
| 85 | public function getEchoDebugLog() |
| 86 | { |
| 87 | return $this->echoDebugLog; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Write an entry to the calculation engine debug log. |
| 92 | */ |
| 93 | public function writeDebugLog(...$args) |
| 94 | { |
| 95 | // Only write the debug log if logging is enabled |
| 96 | if ($this->writeDebugLog) { |
| 97 | $message = implode($args); |
| 98 | $cellReference = implode(' -> ', $this->cellStack->showStack()); |
| 99 | if ($this->echoDebugLog) { |
| 100 | echo $cellReference, |
| 101 | ($this->cellStack->count() > 0 ? ' => ' : ''), |
| 102 | $message, |
| 103 | PHP_EOL; |
| 104 | } |
| 105 | $this->debugLog[] = $cellReference . |
| 106 | ($this->cellStack->count() > 0 ? ' => ' : '') . |
| 107 | $message; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Clear the calculation engine debug log. |
| 113 | */ |
| 114 | public function clearLog() |
| 115 | { |
| 116 | $this->debugLog = []; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Return the calculation engine debug log. |
| 121 | * |
| 122 | * @return string[] |
| 123 | */ |
| 124 | public function getLog() |
| 125 | { |
| 126 | return $this->debugLog; |
| 127 | } |
| 128 | } |
| 129 |