]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/output/debug/console/class_DebugConsoleOutput.php
Continued:
[core.git] / framework / main / classes / output / debug / console / class_DebugConsoleOutput.php
index 80915da609e0e012dfa4bbf2048d2796bbc7159c..140365da8eaf583512d146aff1fdf5a7e27b443f 100644 (file)
@@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Debug\Output;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Debug\Debugger;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
 use Org\Mxchange\CoreFramework\Output\Debug\BaseDebugOutput;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
@@ -15,7 +16,7 @@ use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -33,14 +34,22 @@ use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class DebugConsoleOutput extends BaseDebugOutput implements Debugger, OutputStreamer, Registerable {
+       /**
+        * Cached configuration entry 'debug_*_output_timings'
+        */
+       private $isDebugOutputTimingsEnabled = FALSE;
+
        /**
         * Protected constructor
         *
         * @return      void
         */
        private function __construct () {
-               // Call parent constructor
+               // Call parent constructor first
                parent::__construct(__CLASS__);
+
+               // Cache configuration entry
+               $this->isDebugOutputTimingsEnabled = FrameworkBootstrap::getConfigurationInstance()->isEnabled('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings');
        }
 
        /**
@@ -71,7 +80,7 @@ class DebugConsoleOutput extends BaseDebugOutput implements Debugger, OutputStre
                }
 
                // Are debug times enabled?
-               if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings') == 'Y') {
+               if ($this->isDebugOutputTimingsEnabled) {
                        // Output it first
                        $output = $this->getPrintableExecutionTime() . $output;
                }
@@ -103,7 +112,7 @@ class DebugConsoleOutput extends BaseDebugOutput implements Debugger, OutputStre
         */
        public function streamData (string $data) {
                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+               throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
 }