autogenerate log position informations,
does not need log positions parameters anymore when called
This commit is contained in:
parent
90c055d1cb
commit
7705abd09e
@ -15,11 +15,21 @@ use Doctrine\DBAL\Configuration;
|
||||
*/
|
||||
class OxidEsalesDatabase extends \OxidEsales\Eshop\Core\Database\Adapter\Doctrine\Database
|
||||
{
|
||||
public static function enableLogger($message = null, $file = null, $line = null)
|
||||
public static function enableLogger($message = null)
|
||||
{
|
||||
$trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
|
||||
$database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
|
||||
$dbalConfig = $database->getConnection()->getConfiguration();
|
||||
$dbalConfig->setSQLLogger(new OxidSQLLogger($message, $file, $line));
|
||||
$dbalConfig->setSQLLogger(
|
||||
new OxidSQLLogger(
|
||||
isset($trace[1]['file']) ? $trace[1]['file'] : null,
|
||||
isset($trace[1]['line']) ? $trace[1]['line'] : null,
|
||||
isset($trace[2]['class']) ? $trace[2]['class'] : null,
|
||||
isset($trace[2]['function']) ? $trace[2]['function'] : null,
|
||||
$message
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,21 +16,25 @@ use Monolog;
|
||||
class OxidSQLLogger implements SQLLogger
|
||||
{
|
||||
public $message;
|
||||
public $file;
|
||||
public $line;
|
||||
public $logStartingFile;
|
||||
public $logStartingLine;
|
||||
public $logStartingClass;
|
||||
public $logStartingFunction;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function __construct($message = null, $file = null, $line = null)
|
||||
public function __construct($file, $line, $class, $function, $message = null)
|
||||
{
|
||||
if (!Monolog\Registry::hasLogger('sql')) {
|
||||
Monolog\Registry::addLogger((new LoggerFactory())->create('sql'));
|
||||
}
|
||||
|
||||
$this->message = $message;
|
||||
$this->file = $file;
|
||||
$this->line = $line;
|
||||
$this->logStartingFile = $file;
|
||||
$this->logStartingLine = $line;
|
||||
$this->logStartingClass = $class;
|
||||
$this->logStartingFunction = $function;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,8 +48,11 @@ class OxidSQLLogger implements SQLLogger
|
||||
'query' => $sql,
|
||||
'params' => $params,
|
||||
'types' => $types,
|
||||
'calling_file' => $this->file,
|
||||
'calling_line' => $this->line
|
||||
'logStartingFile' => $this->logStartingFile,
|
||||
'logStartingLine' => $this->logStartingLine,
|
||||
'logStartingClass' => $this->logStartingClass,
|
||||
'logStartingFunction' => $this->logStartingFunction,
|
||||
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
*/
|
||||
|
||||
function D3StartSQLLog($message = null, $file = null, $line = null) {
|
||||
\D3\OxidSqlLogger\OxidEsalesDatabase::enableLogger($message, $file, $line);
|
||||
function D3StartSQLLog($message = null) {
|
||||
\D3\OxidSqlLogger\OxidEsalesDatabase::enableLogger($message);
|
||||
}
|
||||
|
||||
function D3StopSQLLog() {
|
||||
|
Loading…
Reference in New Issue
Block a user