Change Logging class / method name and Debug Support for backtrace
Debug Support: getCallerClass now returns level 1 class from the trace like the getCallerMethod. There is also a new getCallerClassMethod that returns namespace\class->method (or :: for static). getCallerTopLevelClass works like getCallerClass did before and returns the TOP level (first entry on the call stack that has a set class name) Logging: Do not use the Support getCallerClass/Method/File but call it inside and use level 2 in trace to get the data we need For the last call before debug call Also update the strack trace for the debug call to use ->/:: for method type
This commit is contained in:
@@ -4,40 +4,28 @@
|
||||
* TEST sets for DB::IO
|
||||
*/
|
||||
|
||||
namespace Test\DB;
|
||||
|
||||
use CoreLibs\DB\IO;
|
||||
namespace TestCalls\DB;
|
||||
|
||||
class TestDB
|
||||
{
|
||||
/** @var IO */
|
||||
private $db;
|
||||
/** @var array<mixed> */
|
||||
private $config;
|
||||
/** @var \CoreLibs\DB\IO */
|
||||
private \CoreLibs\DB\IO $db;
|
||||
/** @var \CoreLibs\Logging\Logging */
|
||||
private \CoreLibs\Logging\Logging $log;
|
||||
|
||||
/** @var \TestCalls\Test */
|
||||
public $main;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param \CoreLibs\Logging\Logging $log
|
||||
* @param \TestCalls\Test $main
|
||||
*/
|
||||
public function __construct(
|
||||
\CoreLibs\Logging\Logging $log
|
||||
\TestCalls\Test $main
|
||||
) {
|
||||
$this->config = [
|
||||
'db_name' => $_ENV['DB_NAME_TEST'] ?? '',
|
||||
'db_user' => $_ENV['DB_USER_TEST'] ?? '',
|
||||
'db_pass' => $_ENV['DB_PASS_TEST'] ?? '',
|
||||
'db_host' => $_ENV['DB_HOST_TEST'] ?? '',
|
||||
'db_port' => 5432,
|
||||
'db_schema' => 'public',
|
||||
'db_type' => 'pgsql',
|
||||
'db_encoding' => '',
|
||||
'db_ssl' => 'allow'
|
||||
];
|
||||
$this->db = new IO(
|
||||
$this->config,
|
||||
$log
|
||||
);
|
||||
$this->db = $main->db;
|
||||
$this->log = $main->log;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,6 +35,7 @@ class TestDB
|
||||
*/
|
||||
private function testDBa(): void
|
||||
{
|
||||
$this->log->debug('TEST DB', 'Call in testDBa');
|
||||
$this->db->dbInfo();
|
||||
}
|
||||
|
||||
@@ -57,6 +46,7 @@ class TestDB
|
||||
*/
|
||||
public function testRunDB(): void
|
||||
{
|
||||
$this->log->debug('TEST DB', 'Call in testRunDB');
|
||||
$this->testDBa();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,25 +14,33 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Test;
|
||||
namespace TestCalls;
|
||||
|
||||
use Test\DB;
|
||||
use TestCalls\DB;
|
||||
|
||||
class Test
|
||||
{
|
||||
/** @var DB\TestDB */
|
||||
private $test_db;
|
||||
|
||||
/** @var \CoreLibs\DB\IO */
|
||||
public \CoreLibs\DB\IO $db;
|
||||
/** @var \CoreLibs\Logging\Logging */
|
||||
public \CoreLibs\Logging\Logging $log;
|
||||
|
||||
public function __construct(
|
||||
\CoreLibs\DB\IO $db,
|
||||
\CoreLibs\Logging\Logging $log
|
||||
) {
|
||||
$this->db = $db;
|
||||
$this->log = $log;
|
||||
// calls all tests
|
||||
$this->testPrivate();
|
||||
$this->testProtected();
|
||||
$this->testPublic();
|
||||
|
||||
// call intern
|
||||
$this->test_db = new DB\TestDB($log);
|
||||
$this->test_db = new DB\TestDB($this);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
@@ -82,6 +90,28 @@ class Test
|
||||
{
|
||||
$this->test_db->testRunDB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDbCall(): void
|
||||
{
|
||||
$q = <<<SQL
|
||||
SELECT
|
||||
type, sdate, integer
|
||||
FROM
|
||||
foobar
|
||||
LIMIT
|
||||
1;
|
||||
SQL;
|
||||
if (is_array($res = $this->db->dbReturnRow($q))) {
|
||||
print "OUTPUT: " . $this->log->prAr($res);
|
||||
} else {
|
||||
$this->log->error('Failure to run query');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
Reference in New Issue
Block a user