Ejemplo n.º 1
0
  /**
   * Logs the given to a debug log.
   *
   * This method only works if the Log Level is higher than DEBUG.
   * If anything other than a string is passed than the item is var_dumped and then stored.
   * If there is no debug logger object than this method will instantiate it.
   *
   * @see    DocBlock_Abstract::setLogLevel()
   * @see    Zend_Log
   * @param  string|array|object $message
   * @return void
   */
  protected function debug($message)
  {
    // is the log level is below debugging; just skip this
    if ($this->getLogLevel() < Zend_Log::DEBUG)
    {
      return;
    }

    if (!self::$debug_logger)
    {
      $file = str_replace(array('{DATE}'), array(date('YmdHis')), $this->getConfig()->logging->paths->errors);

      self::$debug_logger = new Zend_Log(new Zend_Log_Writer_Stream(fopen($file, 'w')));
    }

    // if the given is not a string then we var dump the object|array to inspect it
    $dump = $message;
    if (!is_string($dump))
    {
      ob_start();
      var_dump($message);
      $dump = ob_get_clean();
    }

    self::$debug_logger->log($dump, Zend_Log::DEBUG);
  }