/** * Adds a log record. * * @param integer $level The logging level * @param string $message The log message * @param array $context The log context * @return Boolean Whether the record has been processed */ public function addRecord($level, $message, array $context = array()) { if (!$this->handlers) { $this->pushHandler(new ehough_epilog_handler_StreamHandler('php://stderr', self::DEBUG)); } if (!self::$timezone) { self::$timezone = new DateTimeZone(date_default_timezone_get() ? date_default_timezone_get() : 'UTC'); } $record = array('message' => (string) $message, 'context' => $context, 'level' => $level, 'level_name' => self::getLevelName($level), 'channel' => $this->name, 'datetime' => $this->_createDateTimeFromFormat('U.u', sprintf('%.6F', microtime(true)), self::$timezone), 'extra' => array()); // check if any handler will handle this message $handlerKey = null; foreach ($this->handlers as $key => $handler) { if ($handler->isHandling($record)) { $handlerKey = $key; break; } } // none found if (null === $handlerKey) { return false; } // found at least one, process message and dispatch it foreach ($this->processors as $processor) { if (is_callable($processor)) { $callback = $processor; } else { $callback = array($processor, '__invoke'); } $record = call_user_func($callback, $record); } while (isset($this->handlers[$handlerKey]) && false === $this->handlers[$handlerKey]->handle($record)) { $handlerKey++; } return true; }