/** * Logs event to a specified backend * * @param string $event Event tag * @param mixed $extra optional Extra data to pass. * @param mixed $extra,... optional * @return boolean Indicates whether operation was successful * @throws AuditLoggerException */ public function log($event, ...$extra) { if (!$this->enabled) { return true; } if (!empty($extra)) { if (array_key_exists($event, $this->subscribers)) { $extra = $this->subscribers[$event](...$extra); } else { $extra = $extra[0]; } } else { $extra = []; } $adjusted = []; foreach ($extra as $key => $val) { if (($pos = strpos($key, '.')) === 0) { //It will adjust data key with the event name when the key either does not contain //dot or starts with dot. $adjusted[$event . $key] = $val; } else { $adjusted[$key] = $val; } } $adjusted = array_merge($this->getCommonData(), $adjusted); $adjusted["tags"] = [$event]; if (!empty($this->defaultTag)) { $adjusted["tags"][] = $this->defaultTag; } $data = ["tag" => $this->defaultTag, "message" => $event, "extra" => $adjusted]; try { $result = $this->writer->send($data); } catch (Exception $e) { \Scalr::logException(new Exception(sprintf("Logger couldn't log the record: %s", $e->getMessage()), $e->getCode(), $e)); $result = false; } return $result; }