diff --git a/src/DB/IO.php b/src/DB/IO.php
index e890ea1..a383710 100644
--- a/src/DB/IO.php
+++ b/src/DB/IO.php
@@ -3123,16 +3123,13 @@ class IO
/**
* switches the debug flag on or off
- * if none given, then return current set only
- * @param bool|null $debug true/false or null for just getting current set
- * @return bool Current debug flag as set
+ *
+ * @param bool $debug True/False to turn debugging in this calss on or off
+ * @return void
*/
- public function dbSetDebug(?bool $debug = null): bool
+ public function dbSetDebug(bool $debug): void
{
- if ($debug !== null) {
- $this->db_debug = $debug;
- }
- return $this->db_debug;
+ $this->db_debug = $debug;
}
/**
@@ -3140,9 +3137,11 @@ class IO
* OR
* with the optional parameter fix sets debug
* returns current set stats
+ *
* @param bool|null $debug Flag to turn debug on off or null for toggle
* @return bool Current debug status
* True for debug is on, False for off
+ * @deprecated Use dbSetDebug and dbGetDebug
*/
public function dbToggleDebug(?bool $debug = null): bool
{
@@ -3156,6 +3155,7 @@ class IO
/**
* Return current set db debug flag status
+ *
* @return bool Current debug status
*/
public function dbGetDebug(): bool
diff --git a/src/Debug/Support.php b/src/Debug/Support.php
index ef492c0..15cdb7a 100644
--- a/src/Debug/Support.php
+++ b/src/Debug/Support.php
@@ -177,7 +177,6 @@ class Support
$caller_level = 1;
$caller_list = self::getCallerMethodList();
if ($caller_list[0] == 'dV') {
- echo "Raise caller level
: " . $caller_list[0] . "
";
$caller_level = 2;
}
// we need to strip the string in log_level === Level::Debug ? true : false;
+ return $this->getLoggingLevel()->includes(
+ Level::Debug
+ );
}
// log file id set (file name prefix)
diff --git a/test/phpunit/DB/CoreLibsDBIOTest.php b/test/phpunit/DB/CoreLibsDBIOTest.php
index 0ad119a..bd145ff 100644
--- a/test/phpunit/DB/CoreLibsDBIOTest.php
+++ b/test/phpunit/DB/CoreLibsDBIOTest.php
@@ -99,7 +99,6 @@ final class CoreLibsDBIOTest extends TestCase
],
];
private static $log;
- private static bool $db_debug = false;
/**
* Test if pgsql module loaded
@@ -123,7 +122,6 @@ final class CoreLibsDBIOTest extends TestCase
'log_file_id' => 'CoreLibs-DB-IO-Test',
]);
// will be true, default logging is true
- self::$db_debug = self::$log->getLoggingLevel()->includes(Level::Debug);
$db = new \CoreLibs\DB\IO(
self::$db_config['valid'],
self::$log
@@ -521,6 +519,9 @@ final class CoreLibsDBIOTest extends TestCase
*/
public function debugSetProvider(): array
{
+ // 0: db connecdtion
+ // 1: override log flag, null for default
+ // 2: set flag
return [
'default debug set' => [
// what base connection
@@ -538,95 +539,46 @@ final class CoreLibsDBIOTest extends TestCase
];
}
- /**
- * test set for toggleDEbug
- *
- * @return array
- */
- public function debugToggleProvider(): array
- {
- return [
- 'default debug set' => [
- // what base connection
- 'valid',
- // actions
- null,
- // toggle is inverse
- self::$db_debug ? true : false,
- ],
- 'toggle debug to false' => [
- 'valid',
- false,
- false,
- ]
- ];
- }
-
/**
* Test dbSetDbug, dbGetDebug
*
* @covers ::dbGetDbug
* @covers ::dbSetDebug
- * @dataProvider debugSetProvider
- * @testdox Setting debug $set will be $expected [$_dataName]
+ * @testdox Set and Get Debug flag
*
* @return void
*/
- public function testDbSetDebug(
- string $connection,
- ?bool $set,
- bool $expected
- ): void {
+ public function testDbSetDebug(): void
+ {
+ $connection = 'valid';
+ // default set, expect true
$db = new \CoreLibs\DB\IO(
self::$db_config[$connection],
self::$log
);
- echo "Expected: " . self::$db_debug . "\n";
- $this->assertEquals(
- $expected,
- $set === null ?
- $db->dbSetDebug() :
- $db->dbSetDebug($set)
+ $this->assertTrue(
+ $db->dbGetDebug()
);
- // must always match
- $this->assertEquals(
- $expected,
+ // switch off
+ $db->dbSetDebug(false);
+ $this->assertFalse(
$db->dbGetDebug()
);
$db->dbClose();
- }
-
- /**
- * Test dbToggleDebug, dbGetDebug
- *
- * @covers ::dbGetDbug
- * @covers ::dbSetDebug
- * @dataProvider debugToggleProvider
- * @testdox Toggle debug $toggle will be $expected [$_dataName]
- *
- * @return void
- */
- public function testDbToggleDebug(
- string $connection,
- ?bool $toggle,
- bool $expected
- ): void {
+ // second conenction with log set NOT debug
+ $log = new \CoreLibs\Logging\Logging([
+ // 'log_folder' => __DIR__ . DIRECTORY_SEPARATOR . 'log',
+ 'log_folder' => DIRECTORY_SEPARATOR . 'tmp',
+ 'log_file_id' => 'CoreLibs-DB-IO-Test',
+ 'log_level' => \CoreLibs\Logging\Logger\Level::Notice,
+ ]);
$db = new \CoreLibs\DB\IO(
self::$db_config[$connection],
- self::$log
+ $log
);
- $this->assertEquals(
- $expected,
- $toggle === null ?
- $db->dbToggleDebug() :
- $db->dbToggleDebug($toggle)
- );
- // must always match
- $this->assertEquals(
- $expected,
+ $this->assertFalse(
$db->dbGetDebug()
);
- $db->dbClose();
}
// - set max query call sets
diff --git a/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php b/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php
index fd75ebd..177545b 100644
--- a/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php
+++ b/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php
@@ -217,14 +217,14 @@ final class CoreLibsLoggingLoggingTest extends TestCase
// setLoggingLevel
// getLoggingLevel
- // getJsDebug
+ // loggingLevelIsDebug
/**
* Undocumented function
*
* @covers ::setLoggingLevel
* @covers ::getLoggingLevel
- * @covers ::getJsDebug
+ * @covers ::loggingLevelIsDebug
* @testdox setLoggingLevel set/get checks
*
* @return void
@@ -242,7 +242,7 @@ final class CoreLibsLoggingLoggingTest extends TestCase
$log->getLoggingLevel()
);
$this->assertFalse(
- $log->getJsDebug()
+ $log->loggingLevelIsDebug()
);
// not set, should be debug]
$log = new \CoreLibs\Logging\Logging([
@@ -254,7 +254,7 @@ final class CoreLibsLoggingLoggingTest extends TestCase
$log->getLoggingLevel()
);
$this->assertTrue(
- $log->getJsDebug()
+ $log->loggingLevelIsDebug()
);
// invalid, should be debug, will throw excpetion too
$this->expectException(\InvalidArgumentException::class);
@@ -269,7 +269,7 @@ final class CoreLibsLoggingLoggingTest extends TestCase
$log->getLoggingLevel()
);
$this->assertTrue(
- $log->getJsDebug()
+ $log->loggingLevelIsDebug()
);
// set valid, then change
$log = new \CoreLibs\Logging\Logging([