autogenerate log position informations,
does not need log positions parameters anymore when called
Cette révision appartient à :
Parent
90c055d1cb
révision
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->message = $message;
|
||||
$this->logStartingFile = $file;
|
||||
$this->logStartingLine = $line;
|
||||
$this->logStartingClass = $class;
|
||||
$this->logStartingFunction = $function;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,11 +45,14 @@ class OxidSQLLogger implements SQLLogger
|
||||
Monolog\Registry::sql()->addDebug(
|
||||
$this->message ? $this->message : $sql,
|
||||
[
|
||||
'query' => $sql,
|
||||
'params' => $params,
|
||||
'types' => $types,
|
||||
'calling_file' => $this->file,
|
||||
'calling_line' => $this->line
|
||||
'query' => $sql,
|
||||
'params' => $params,
|
||||
'types' => $types,
|
||||
'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() {
|
||||
|
Chargement…
Référencer dans un nouveau ticket
Block a user