6 public static function write($data)
8 if (!is_array($data[
'USER_ID']))
10 $data[
'USER_ID'] = [(int)$data[
'USER_ID']];
14 foreach ($data[
'USER_ID'] as $uid)
28 $action = $data[
'ACTION']?:
'UNKNOWN';
29 $params = $data[
'PARAMS']?: [];
30 $device = $data[
'DEVICE']?:
'UNKNOWN';
34 if (!in_array((
int)$USER->GetID(), $users,
true))
39 $logUserId = $USER->GetID();
41 $sessionId = \Bitrix\Main\Application::getInstance()->getKernelSession()->getId();
42 $logName = md5($sessionId);
43 $scriptName = \Bitrix\Main\Context::getCurrent()->getServer()->getScriptName();
44 $userIp = \Bitrix\Main\Context::getCurrent()->getRequest()->getRemoteAddress();
45 if ($device ===
'UNKNOWN')
47 $device = mb_strpos($scriptName,
'desktop_app')?
'DESKTOP' :
'BROWSER';
50 $log =
"\n------------------------\n";
51 $log .= date(
"Y.m.d G:i:s").
"\n";
52 $log .= $action.
' ['.$device.
' - '.$userIp.
' :: '.$sessionId.
"]\n";
53 $log .= print_r($params, 1);
54 $log .=
"\n------------------------\n";
56 \Bitrix\Main\IO\File::putFileContents($_SERVER[
"DOCUMENT_ROOT"].
"/../logs/im/$logUserId/$logName.log", $log, \
Bitrix\Main\
IO\File::APPEND);