diff --git a/runtime/lib/connection/PropelPDO.php b/runtime/lib/connection/PropelPDO.php index 1a30d3b4c..3c80eb13b 100644 --- a/runtime/lib/connection/PropelPDO.php +++ b/runtime/lib/connection/PropelPDO.php @@ -647,6 +647,24 @@ public function log($msg, $level = null, $methodName = null, array $debugSnapsho } } + /** + * Returns a string with files, lines e functions of the stacktrace to this method + * + * @return str + */ + function generateCallTrace() + { + $stacktrace = debug_backtrace(2); + $stackLog = ''; + foreach ($stacktrace as $stack) { + $file = isset($stack['file']) ? $stack['file'] : "Unknown file"; + $line = isset($stack['line']) ? $stack['line'] : "Unknown line"; + $stackLog .= $file.':'.$line.' '.$stack['function']."()\n"; + } + + return $stackLog; + } + /** * Returns a snapshot of the current values of some functions useful in debugging. * @@ -661,6 +679,7 @@ public function getDebugSnapshot() 'microtime' => microtime(true), 'memory_get_usage' => memory_get_usage($this->getLoggingConfig('realmemoryusage', false)), 'memory_get_peak_usage' => memory_get_peak_usage($this->getLoggingConfig('realmemoryusage', false)), + 'stacktrace' => $this->generateCallTrace(), ); } else { throw new PropelException('Should not get debug snapshot when not debugging'); @@ -754,6 +773,10 @@ protected function getLogPrefix($methodName, $debugSnapshot) $value = $this->connectionName; break; + case 'stacktrace': + $value = $debugSnapshot['stacktrace']; + break; + default: $value = 'n/a'; break;