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;
}