/** * Logs the method call or SQL using the Propel::log() method or a registered logger class. * * @uses self::getLogPrefix() * @see self::setLogger() * * @param string $msg Message to log. * @param integer $level Log level to use; will use self::setLogLevel() specified level by default. * @param string $methodName Name of the method whose execution is being logged. */ public function log($msg, $level = null, $methodName = null) { // If logging has been specifically disabled, this method won't do anything if (!$this->getLoggingConfig('enabled', true)) { return; } // If the method being logged isn't one of the ones to be logged, bail if (!in_array($methodName, $this->getLoggingConfig('methods', static::$defaultLogMethods))) { return; } // If a logging level wasn't provided, use the default one if ($level === null) { $level = $this->logLevel; } // We won't log empty messages if (!$msg) { return; } // Delegate the actual logging forward if ($this->logger) { $this->logger->log($msg, $level); } else { Propel::log($msg, $level); } }
/** * Logs the SQL using the Propel::log() method or registered logger class. * * @param string $msg Message to log. * @param int $level (optional) Log level to use; will use setLogLevel() specified level by default. * @see setLogger() * @see */ public function log($msg, $level = null) { if ($level === null) { $level = $this->logLevel; } if ($this->logger) { $this->logger->log($msg, $level); } else { Propel::log($msg, $level); } }
/** * Logs the method call or SQL using the Propel::log() method or a registered logger class. * * @uses self::getLogPrefix() * @see self::setLogger() * * @param string $msg Message to log. * @param int $level (optional) Log level to use; will use self::setLogLevel() specified level by default. * @param string $methodName (optional) Name of the method whose execution is being logged. * @param array $debugSnapshot (optional) Previous return value from self::getDebugSnapshot(). */ public function log($msg, $level = null, $methodName = null, array $debugSnapshot = null) { // If logging has been specifically disabled, this method won't do anything if (!$this->getLoggingConfig('enabled', true)) { return; } // If the method being logged isn't one of the ones to be logged, bail if (!in_array($methodName, $this->getLoggingConfig('methods', self::$defaultLogMethods))) { return; } // If a logging level wasn't provided, use the default one if ($level === null) { $level = $this->logLevel; } // Determine if this query is slow enough to warrant logging if ($this->getLoggingConfig("onlyslow", self::DEFAULT_ONLYSLOW_ENABLED)) { $now = $this->getDebugSnapshot(); if ($now['microtime'] - $debugSnapshot['microtime'] < $this->getLoggingConfig("details.slow.threshold", self::DEFAULT_SLOW_THRESHOLD)) { return; } } // If the necessary additional parameters were given, get the debug log prefix for the log line if ($methodName && $debugSnapshot) { $msg = $this->getLogPrefix($methodName, $debugSnapshot) . $msg; } // We won't log empty messages if (!$msg) { return; } // Delegate the actual logging forward if ($this->logger) { $this->logger->log($msg, $level); } else { Propel::log($msg, $level); } }