3 namespace Org\Mxchange\CoreFramework\Debug\Output;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
7 use Org\Mxchange\CoreFramework\Debug\Debugger;
8 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
9 use Org\Mxchange\CoreFramework\Output\Debug\BaseDebugOutput;
10 use Org\Mxchange\CoreFramework\Registry\Registerable;
11 use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
14 * A debug output class for the console (e.g. hub software)
16 * @author Roland Haeder <webmaster@shipsimu.org>
18 <<<<<<< HEAD:framework/main/classes/output/debug/console/class_DebugConsoleOutput.php
19 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
21 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
22 >>>>>>> Some updates::inc/main/classes/output/debug/console/class_DebugConsoleOutput.php
23 * @license GNU GPL 3.0 or any newer version
24 * @link http://www.shipsimu.org
26 * This program is free software: you can redistribute it and/or modify
27 * it under the terms of the GNU General Public License as published by
28 * the Free Software Foundation, either version 3 of the License, or
29 * (at your option) any later version.
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public License
37 * along with this program. If not, see <http://www.gnu.org/licenses/>.
39 class DebugConsoleOutput extends BaseDebugOutput implements Debugger, OutputStreamer, Registerable {
41 * Protected constructor
45 protected function __construct () {
46 // Call parent constructor
47 parent::__construct(__CLASS__);
51 * Creates an instance of this class
53 * @return $debugInstance The prepared debug instance
55 public static final function createDebugConsoleOutput () {
57 $debugInstance = new DebugConsoleOutput();
60 return $debugInstance;
64 * Outputs the given data without HTML tags
66 * @param $output The HTML'ed output
67 * @param $stripTags Whether HTML tags shall be stripped out
70 public final function outputStream ($output, $stripTags = false) {
71 // Strip HTML tags out?
72 if ($stripTags === true) {
73 // Prepare the output without HTML tags
74 $output = trim(html_entity_decode(strip_tags(stripslashes($output))));
77 // Are debug times enabled?
78 if ($this->getConfigInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings') == 'Y') {
80 $output = $this->getPrintableExecutionTime() . $output;
83 // And print it out...
84 printf('%s%s', str_replace('->', '->', $output), PHP_EOL);
90 * @param $outStream Stream to output
91 * @param $stripTags Whether HTML tags shall be stripped out
94 public final function output ($outStream = false, $stripTags = false) {
95 // Empty output will be silently ignored
96 if ($outStream !== false) {
97 $this->outputStream($outStream, $stripTags);
102 * Streams the data and maybe does something to it
104 * @param $data The data (string mostly) to "stream"
105 * @return $data The data (string mostly) to "stream"
106 * @throws UnsupportedOperationException If this method is called
108 public function streamData ($data) {
109 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
110 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
114 * Determines seek position
116 * @return $seekPosition Current seek position
117 * @throws UnsupportedOperationException If this method is called
119 public function determineSeekPosition () {
120 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
124 * Seek to given offset (default) or other possibilities as fseek() gives.
126 * @param $offset Offset to seek to (or used as "base" for other seeks)
127 * @param $whence Added to offset (default: only use offset to seek to)
128 * @return $status Status of file seek: 0 = success, -1 = failed
129 * @throws UnsupportedOperationException If this method is called
131 public function seek ($offset, $whence = SEEK_SET) {
132 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
133 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
139 * @return $size Size (in bytes) of file
140 * @throws UnsupportedOperationException If this method is called
142 public function size () {
143 throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);