From 07fcca498d0b9c9a775334ddc5d32825cf7a3fdf Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Fri, 1 May 2020 01:08:23 +0200 Subject: [PATCH] remove Query Status Monitor, complete implementation --- .travis.yml | 16 ----- CHANGELOG.md | 5 +- README.md | 24 ------- composer.json | 10 +-- img/sql-query-status-monitor.jpg | Bin 10130 -> 0 bytes phpspec.yml | 4 -- spec/OxidSQLLoggerSpec.php | 89 -------------------------- spec/SQLQuerySpec.php | 65 ------------------- src/AutoInstallSmaryPlugin.php | 57 ----------------- src/OxidSQLLogger.php | 8 ++- src/OxidUtilsView.php | 24 ------- src/SQLQuery.php | 32 +++++++++ src/Smarty/function.tm_sql_status.php | 55 ---------------- src/functions.php | 2 - 14 files changed, 40 insertions(+), 351 deletions(-) delete mode 100644 .travis.yml delete mode 100644 img/sql-query-status-monitor.jpg delete mode 100644 phpspec.yml delete mode 100644 spec/OxidSQLLoggerSpec.php delete mode 100644 spec/SQLQuerySpec.php delete mode 100644 src/AutoInstallSmaryPlugin.php delete mode 100644 src/OxidUtilsView.php delete mode 100644 src/Smarty/function.tm_sql_status.php diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bf83d90..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: php - -php: - - 7.0 - -cache: - directories: - - $HOME/.composer/cache - -before_script: - - composer install - -script: - - php ./vendor/bin/phpspec run --format=pretty --stop-on-failure --no-code-generation - - diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a2b851..bacbd59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- -## [1.2.0] - 2019-10-01 +## [1.2.0] - 2020-04-30 ### Added -- SQL Query Monitor show at the Page how many SQL queries have been fired. +- Format SQL query - Measures the SQL execution time -- Testing framework [phpspec](https://www.phpspec.net/en/stable/manual/introduction.html) --- diff --git a/README.md b/README.md index e35db96..65c88de 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ Oxid eShop SQL Logger --------------------- -[![Build Status](https://travis-ci.org/TumTum/oxid-sql-logger.svg?branch=master)](https://travis-ci.org/TumTum/oxid-sql-logger) - Returns all SQL queries into console of a Browser. ## Install @@ -32,28 +30,6 @@ CLI: ![Example CLI](https://raw.githubusercontent.com/d3datadevelopment/oxid-sql-logger/master/img/screenshot-cli.jpg) -## SQL Query Status Monitor - -![Example CLI](https://raw.githubusercontent.com/TumTum/oxid-sql-logger/master/img/sql-query-status-monitor.jpg) - -See how many queries and which types of queries have been added to the database. -To determine the amount. - -#### Switch on - -For this purpose, the parameter `$this->blSQLStatusBox = true;` must be stored in the file `config.inc.php`. -So you can turn it on and off temporarily. - -Unique: Insert, at the end, the Smarty tag: `[{tm_sql_status}]` in the `base.tpl` file. - -####### source/Application/views/flow/tpl/layout/base.tpl - -```html - [{tm_sql_status}] - - -``` - ## Credits Many thanks to [Tobias Matthaiou](https://github.com/TumTum/oxid-sql-logger) for his inspiration. diff --git a/composer.json b/composer.json index 4990a51..52d7e90 100644 --- a/composer.json +++ b/composer.json @@ -6,19 +6,11 @@ "monolog/monolog": "^1", "nilportugues/sql-query-formatter": "^1.2.2" }, - "require-dev": { - "phpspec/phpspec": "^4", - "doctrine/dbal": "^2.5", - "bovigo/assert": "^2" - }, "license": "GPL-3.0", "autoload": { "psr-4": { "D3\\OxidSqlLogger\\": "./src" - }, - "files": [ - "./src/functions.php" - ] + } }, "authors": [ { diff --git a/img/sql-query-status-monitor.jpg b/img/sql-query-status-monitor.jpg deleted file mode 100644 index 9a199e6c20cb91e798e5eeaa7c2f2f93bc2cc5cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10130 zcmeHLc|4Tu*S{@UlkAl;2qnvu5WbJe0pZ<70@4s*7p1JRHpZnU*IoEZa?{(;J=<~pSBRxYsfQbnJ z3>X(cCjz&1(TE!W0EYu7007_sn3?zi76!+}xPWK`!1|L102#&;09aF_0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BVa_)@$|z-cp2HM>fVGl z0T53#jVrBc8y7?$-DdB)=aKzrj5q45VEF8L8SMK(@gz={#Fe7Bu?J%}Pc$nb*Op~Z z@Ll~PS~fG7P=k-M7ayUCV$4T0ZRYn-vcYJQSZU=OFnF!f@la%B|6 zG)t(X`N`tIK5yRPjVs$KNP&Sh-*%WAlogF_7Xw=8z@G!-$~(v|d+~`D{eaS<$KLWb zmMy77R6{jt&5BTxqB3z#3sn!n~$2PTtt zoW9I;i&$r1cXE)$9*JBvE1sFW=r0vMRaRZ%@17W~C&Dd>$KqPlDWAG%r(ir^*A9Nn ztU}*(Cq$)@+?5}YP%=XojyKf@8@=w|?zUL(mQ1;)CIuPtkUOTUU6MDBmAFQrUL%Y2 z4nn}fi(qgd2`E$&bcZlV08iWXyI7gJVt>$+9SpX z5*HwX%MN?L&fG+5pF-IfPgZEc_vGd9Buq>^jl!C0+?UZy9MKEjeDe7u+vnqu;9>ZP zUH1yaxgB$6evto7$Z*~n%FGNlGk=*TIwUW@N_{h!oGwo_> z-#%^HfUb<3No1$V5Y?F6XuP6`WEF z@}_ee7Mn&N;|XW2zMXXdje{3Lr;b^IaN-G&nR*Huv1c%9BbjIFV}M9TeOljyudSW!TjA;q zs|=Wu&*5`*n_O09;Y{DNZci)S;VDL?ZM4vWTnjN z5gmd-_gfLwmAW85X_v_HOz|Y-X_{bYa_EOfDkH7*9Lf>8u40cZqysPXAfN~>9NAb> zH1XO*b~QPdapcekw`lQLM%I&=98CvKUk>d^rmXFVz!({lJw#sGjq(q1Ct8b|fxH7U)sYTEW c)&}+_EtiRMXY>aZ3tq09tw2Z@!01!|13*;9^8f$< diff --git a/phpspec.yml b/phpspec.yml deleted file mode 100644 index 66f8981..0000000 --- a/phpspec.yml +++ /dev/null @@ -1,4 +0,0 @@ -suites: - default: - namespace: "tm\\oxid\\sql\\logger\\" - psr4_prefix: "tm\\oxid\\sql\\logger\\" diff --git a/spec/OxidSQLLoggerSpec.php b/spec/OxidSQLLoggerSpec.php deleted file mode 100644 index 1e8834d..0000000 --- a/spec/OxidSQLLoggerSpec.php +++ /dev/null @@ -1,89 +0,0 @@ -testLogger = new Monolog\Handler\TestHandler(); - Monolog\Registry::addLogger( - new Monolog\Logger('sql', [$this->testLogger]), - 'sql', - true - ); - } - - public function it_is_initializable() - { - $this->shouldHaveType(OxidSQLLogger::class); - } - - /** - * @throws FailureException - */ - public function it_should_log_the_sql_normally() - { - $this->startQuery('SELECT 1', ['param1'], ['master']); - for ($i = 0; $i <= 1000; $i++) @get_declared_classes(); - $this->stopQuery(); - - $this->assertExpectLog(); - $this->assertMatchMessage('/\[\d+ms\] SELECT 1/'); - - $this->assertContext('params', isSameAs(['param1'])); - $this->assertContext('types', isSameAs(['master'])); - $this->assertContext('time', isOfType('float')); - - } - - /** - * @throws FailureException - */ - public function it_should_log_without_time_specification() - { - $this->startQuery('SELECT 1'); - $this->startQuery('SELECT 2'); - - $this->assertExpectLog(); - $this->assertMatchMessage('/\[Statement canceled\] SELECT 1/'); - $this->assertContext('time', isSameAs('Statement canceled')); - - } - - private function assertExpectLog() - { - if (!$this->testLogger->hasRecords(Monolog\Logger::DEBUG)) { - throw new FailureException("No log entry was made"); - } - } - - private function assertMatchMessage($regex) - { - if (!$this->testLogger->hasRecordThatMatches($regex, Monolog\Logger::DEBUG)) { - $message = $this->testLogger->getRecords()[0]['message']; - throw new FailureException("Expect message '{$regex}' got '{$message}'"); - }; - } - - private function assertContext($param, $actual) - { - $record = $this->testLogger->getRecords()[0]; - - \bovigo\assert\assert($record['context'], hasKey($param), "Context '{$param}' not found"); - \bovigo\assert\assert($record['context'][$param], $actual, "Context '{$param} is not same"); - } -} diff --git a/spec/SQLQuerySpec.php b/spec/SQLQuerySpec.php deleted file mode 100644 index 5ef7009..0000000 --- a/spec/SQLQuerySpec.php +++ /dev/null @@ -1,65 +0,0 @@ -shouldHaveType(SQLQuery::class); - } - - public function it_hat_sql_setter_getter() - { - $this->setSQL('SELECT NOW()')->shouldHaveType(SQLQuery::class); - $this->getSQL()->shouldBe('SELECT NOW()'); - } - - public function it_hat_params_setter_getter() - { - $this->setParams(['param1', 'param2'])->shouldHaveType(SQLQuery::class); - $this->getParams()->shouldBe(['param1', 'param2']); - } - - public function it_hat_type_setter_getter() - { - $this->setTypes(['type1'])->shouldHaveType(SQLQuery::class); - $this->getTypes()->shouldBe(['type1']); - } - - public function it_should_indicate_an_aborted_time() - { - $this->setSql('SELECT 1'); - $this->setCanceled()->shouldHaveType(SQLQuery::class); - $this->getElapsedTime()->shouldBe('Statement canceled'); - } - - public function it_should_display_with_a_readable_time() - { - $this->setSql('SELECT 1'); - sleep(1); - $this->getReadableElapsedTime()->shouldMatch('/^1\.\d\d\ds/'); - } - - public function it_should_display_with_a_readable_time_in_ms() - { - $this->setSql('SELECT 1'); - for ($i = 0; $i <= 1000; $i++) @get_declared_classes(); - $this->getReadableElapsedTime()->shouldMatch('/^\d{1,3}ms/'); - } - - public function it_should_display_a_time_in_float() - { - $this->setSql('SELECT 1'); - for ($i = 0; $i <= 1000; $i++) @get_declared_classes(); - $this->getElapsedTime()->shouldBeFloat(); - } -} diff --git a/src/AutoInstallSmaryPlugin.php b/src/AutoInstallSmaryPlugin.php deleted file mode 100644 index 0e02a91..0000000 --- a/src/AutoInstallSmaryPlugin.php +++ /dev/null @@ -1,57 +0,0 @@ - - * Date: 2019-08-20 - * Time: 21:33 - */ - -namespace D3\OxidSqlLogger; - -/** - * Class AutoInstallSmaryPlugin - */ -class AutoInstallSmaryPlugin -{ - public function runInstall() - { - $oxideshop_ce = new \SplFileInfo(__DIR__ . '/../../../oxid-esales/oxideshop-ce/source/Core/Smarty/Plugin'); - $smartyPlugin = new \SplFileInfo(__DIR__ . '/Smarty/function.tm_sql_status.php'); - - if ($oxideshop_ce->isDir()) { - - $target = new \SplFileInfo($oxideshop_ce->getRealPath() . '/' . $smartyPlugin->getBasename()); - - if ($target->isFile() && $this->isSameFile($target, $smartyPlugin)) { - return; - } - - $this->createHardLink($smartyPlugin, $target); - - OxidUtilsView::clearSmarty(); - } - } - - /** - * @param \SplFileInfo $target - * @param \SplFileInfo $ - * @return bool - */ - protected function isSameFile(\SplFileInfo $target, \SplFileInfo $smartyPlugin) - { - return @md5_file($target->getPathname()) == @md5_file($smartyPlugin->getRealPath()); - } - - /** - * @param \SplFileInfo $smarty_func_tm_sql_status - * @param \SplFileInfo $target - */ - protected function createHardLink(\SplFileInfo $smartyPlugin, \SplFileInfo $target) - { - if ($target->isFile()) { - @unlink($target->getPathname()); - } - - link($smartyPlugin->getPathname(), $target->getPathname()); - } -} - diff --git a/src/OxidSQLLogger.php b/src/OxidSQLLogger.php index 6b068e1..b4d7bc1 100644 --- a/src/OxidSQLLogger.php +++ b/src/OxidSQLLogger.php @@ -9,6 +9,7 @@ namespace D3\OxidSqlLogger; use Doctrine\DBAL\Logging\SQLLogger; use Monolog; +use NilPortugues\Sql\QueryFormatter\Formatter; /** * Class OxidSQLLogger @@ -47,14 +48,12 @@ class OxidSQLLogger implements SQLLogger */ public function startQuery($sql, array $params = null, array $types = null) { - $formatter = new Formatter(); - if ($this->SQLQuery) { $this->SQLQuery->setCanceled(); $this->stopQuery(); } - $this->SQLQuery = (new SQLQuery()) ->setSql($formatter->format($sql)) + $this->SQLQuery = (new SQLQuery()) ->setSql($sql) ->setParams($params) ->setTypes($types) ->setLogStartingFile($this->logStartingFile) @@ -69,9 +68,12 @@ class OxidSQLLogger implements SQLLogger public function stopQuery() { if ($this->SQLQuery) { + $formatter = new Formatter(); + Monolog\Registry::sql()->addDebug( '['.$this->SQLQuery->getReadableElapsedTime().'] ' . ( $this->message ? $this->message : $this->SQLQuery->getSql() ), [ + 'query' => $formatter->format($this->SQLQuery->getSql()), 'params' => $this->SQLQuery->getParams(), 'time' => $this->SQLQuery->getElapsedTime(), 'types' => $this->SQLQuery->getTypes(), diff --git a/src/OxidUtilsView.php b/src/OxidUtilsView.php deleted file mode 100644 index 451e257..0000000 --- a/src/OxidUtilsView.php +++ /dev/null @@ -1,24 +0,0 @@ - - * Date: 2019-08-20 - * Time: 21:33 - */ - -namespace D3\OxidSqlLogger; - -/** - * Class OxidUtilsView - * @package tm\oxid\sql\logger - */ -class OxidUtilsView extends \OxidEsales\Eshop\Core\UtilsView -{ - - /** - * Removes existing Smarty instance - */ - public static function clearSmarty() - { - \OxidEsales\Eshop\Core\UtilsView::$_oSmarty = null; - } -} diff --git a/src/SQLQuery.php b/src/SQLQuery.php index 363dafd..0b61fb1 100644 --- a/src/SQLQuery.php +++ b/src/SQLQuery.php @@ -108,6 +108,14 @@ class SQLQuery return $this; } + /** + * @return string + */ + public function getLogStartingFile() + { + return $this->logStartingFile; + } + /** * @param $file * @return SQLQuery @@ -117,6 +125,14 @@ class SQLQuery $this->logStartingFile = $file; return $this; } + + /** + * @return string + */ + public function getLogStartingLine() + { + return $this->logStartingLine; + } /** * @param $line @@ -127,6 +143,14 @@ class SQLQuery $this->logStartingLine = $line; return $this; } + + /** + * @return string + */ + public function getLogStartingClass() + { + return $this->logStartingClass; + } /** * @param $classname @@ -137,6 +161,14 @@ class SQLQuery $this->logStartingClass = $classname; return $this; } + + /** + * @return string + */ + public function getLogStartingFunction() + { + return $this->logStartingFunction; + } /** * @param $functionname diff --git a/src/Smarty/function.tm_sql_status.php b/src/Smarty/function.tm_sql_status.php deleted file mode 100644 index 433bc98..0000000 --- a/src/Smarty/function.tm_sql_status.php +++ /dev/null @@ -1,55 +0,0 @@ -blSQLStatusBox = true -* ------------------------------------------------------------- -*/ -function smarty_function_tm_sql_status($aParams, &$smarty) -{ - $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig(); - - // muss in config.inc.php gesetzt sein - - $box = $myConfig->getConfigParam('blSQLStatusBox'); - - if ($box == false) { - return ''; - } - - $db = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC); - $query = "SHOW STATUS WHERE Variable_name IN ( 'Com_select', 'Com_update', 'Com_insert', 'Com_delete' )"; - - $iSelects = $iDeletes = $iInserts = $iUpdates = 0; - $rows = $db->getAll($query); - foreach ($rows as $row) { - switch ($row['Variable_name']) { - case 'Com_select': - $iSelects = (int)$row['Value']; - break; - case 'Com_update': - $iUpdates = (int)$row['Value']; - break; - case 'Com_insert': - $iInserts = (int)$row['Value']; - break; - case 'Com_delete': - $iDeletes = (int)$row['Value']; - break; - default: - break; - } - } - - $iSum = $iSelects + $iDeletes + $iInserts + $iUpdates; - $sTable = ''; - $sTable .= ''; - $sTable .= ""; - $sTable .= '
All: $iSum SELECT: $iSelects UPDATE: $iUpdates INSERT: $iInserts DELETE: $iDeletes
'; - - return $sTable; -} diff --git a/src/functions.php b/src/functions.php index 4a9d318..0571331 100644 --- a/src/functions.php +++ b/src/functions.php @@ -12,5 +12,3 @@ function D3StartSQLLog($message = null) { function D3StopSQLLog() { \D3\OxidSqlLogger\OxidEsalesDatabase::disableLogger(); } - -// (new \D3\OxidSqlLogger\AutoInstallSmaryPlugin())->runInstall();