diff --git a/examples/tracy-and-exceptions.php b/examples/tracy-and-exceptions.php
index 4fb1163..afb43c1 100644
--- a/examples/tracy-and-exceptions.php
+++ b/examples/tracy-and-exceptions.php
@@ -13,9 +13,6 @@ Tracy\Debugger::enable();
$dibi = new Dibi\Connection([
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
- 'profiler' => [
- 'run' => true,
- ],
]);
diff --git a/examples/tracy.php b/examples/tracy.php
index d14709a..bff98b8 100644
--- a/examples/tracy.php
+++ b/examples/tracy.php
@@ -13,9 +13,6 @@ Tracy\Debugger::enable();
$dibi = new Dibi\Connection([
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
- 'profiler' => [
- 'run' => true,
- ],
]);
diff --git a/examples/using-logger.php b/examples/using-logger.php
index c0c6298..23e359e 100644
--- a/examples/using-logger.php
+++ b/examples/using-logger.php
@@ -19,8 +19,7 @@ $dibi = new Dibi\Connection([
'database' => 'data/sample.s3db',
// enable query logging to this file
'profiler' => [
- 'run' => true,
- 'file' => 'data/log.sql',
+ 'file' => 'log/log.sql',
],
]);
@@ -37,6 +36,6 @@ try {
// outputs a log file
-echo '
File data/log.sql:
';
+echo 'File log/log.sql:
';
-echo '', file_get_contents('data/log.sql'), '
';
+echo '', file_get_contents('log/log.sql'), '
';
diff --git a/examples/using-profiler.php b/examples/using-profiler.php
deleted file mode 100644
index ed46fa2..0000000
--- a/examples/using-profiler.php
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-Using Profiler | dibi
-
- 'sqlite3',
- 'database' => 'data/sample.s3db',
- 'profiler' => [
- 'run' => true,
- ],
-]);
-
-
-// execute some queries...
-for ($i = 0; $i < 20; $i++) {
- $res = $dibi->query('SELECT * FROM [customers] WHERE [customer_id] < ?', $i);
-}
-
-// display output
-?>
-Last query: = dibi::$sql; ?>
-
-Number of queries: = dibi::$numOfQueries; ?>
-
-Elapsed time for last query: = sprintf('%0.3f', dibi::$elapsedTime * 1000); ?> ms
-
-Total elapsed time: = sprintf('%0.3f', dibi::$totalTime * 1000); ?> ms
-
-
-
-Dibi can log to your Firebug Console. You first need to install the Firefox, Firebug and FirePHP extensions. You can install them from here:
-
-
- - Firebug: https://addons.mozilla.org/en-US/firefox/addon/1843
-
- FirePHP: http://www.firephp.org/
-
diff --git a/src/Dibi/Connection.php b/src/Dibi/Connection.php
index b57365e..82059ff 100644
--- a/src/Dibi/Connection.php
+++ b/src/Dibi/Connection.php
@@ -46,7 +46,7 @@ class Connection implements IConnection
* - lazy (bool) => if true, connection will be established only when required
* - result (array) => result set options
* - formatDateTime => date-time format (if empty, DateTime objects will be returned)
- * - profiler (array or bool)
+ * - profiler (array)
* - run (bool) => enable profiler?
* - file => file to log
* - substitutes (array) => map of driver specific substitutes (under development)
@@ -97,20 +97,9 @@ class Connection implements IConnection
$this->config = $config;
// profiler
- $profilerCfg = &$config['profiler'];
- if (is_scalar($profilerCfg)) {
- $profilerCfg = ['run' => (bool) $profilerCfg];
- }
- if (!empty($profilerCfg['run'])) {
- $filter = $profilerCfg['filter'] ?? Event::QUERY;
-
- if (isset($profilerCfg['file'])) {
- $this->onEvent[] = [new Loggers\FileLogger($profilerCfg['file'], $filter), 'logEvent'];
- }
-
- if (Loggers\FirePhpLogger::isAvailable()) {
- $this->onEvent[] = [new Loggers\FirePhpLogger($filter), 'logEvent'];
- }
+ if (isset($config['profiler']['file']) && (!isset($config['profiler']['run']) || $config['profiler']['run'])) {
+ $filter = $config['profiler']['filter'] ?? Event::QUERY;
+ $this->onEvent[] = [new Loggers\FileLogger($config['profiler']['file'], $filter), 'logEvent'];
}
$this->substitutes = new HashMap(function ($expr) { return ":$expr:"; });
diff --git a/src/Dibi/Loggers/FirePhpLogger.php b/src/Dibi/Loggers/FirePhpLogger.php
deleted file mode 100644
index ef5ad7f..0000000
--- a/src/Dibi/Loggers/FirePhpLogger.php
+++ /dev/null
@@ -1,92 +0,0 @@
-filter = $filter ?: Dibi\Event::QUERY;
- }
-
-
- /**
- * After event notification.
- */
- public function logEvent(Dibi\Event $event): void
- {
- if (headers_sent() || ($event->type & $this->filter) === 0 || count(self::$fireTable) > self::$maxQueries) {
- return;
- }
-
- if (!$this->numOfQueries) {
- header('X-Wf-Protocol-dibi: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
- header('X-Wf-dibi-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.2.0');
- header('X-Wf-dibi-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
- }
- $this->totalTime += $event->time;
- $this->numOfQueries++;
- self::$fireTable[] = [
- sprintf('%0.3f', $event->time * 1000),
- strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql,
- $event->result instanceof \Exception ? 'ERROR' : (string) $event->count,
- $event->connection->getConfig('driver') . '/' . $event->connection->getConfig('name'),
- ];
-
- $payload = json_encode([
- [
- 'Type' => 'TABLE',
- 'Label' => 'dibi profiler (' . $this->numOfQueries . ' SQL queries took ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms)',
- ],
- self::$fireTable,
- ]);
- foreach (str_split($payload, self::$streamChunkSize) as $num => $s) {
- $num++;
- header("X-Wf-dibi-1-1-d$num: |$s|\\"); // protocol-, structure-, plugin-, message-index
- }
- header("X-Wf-dibi-1-1-d$num: |$s|");
- }
-}