Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
logger.php
1<?php
2
4
9
14class Logger
15{
16 const E_ALL = 0;
17 const E_ERROR = 1;
18
26 public static function addError($error)
27 {
28 if (!is_string($error))
29 {
30 throw new ArgumentTypeException('$error', 'string');
31 }
32
33 if ($error === '')
34 {
35 return;
36 }
37
38 if (self::getLevel() > static::E_ERROR)
39 {
40 return;
41 }
42
43 PaySystemErrLogTable::add([
44 'DATE_INSERT' => new DateTime(),
45 'MESSAGE' => $error,
46 ]);
47 }
48
56 public static function addDebugInfo($debugInfo)
57 {
58 if (!is_string($debugInfo))
59 {
60 throw new ArgumentTypeException('$debugInfo', 'string');
61 }
62
63 if (self::getLevel() !== static::E_ALL)
64 {
65 return;
66 }
67
68 PaySystemErrLogTable::add([
69 'DATE_INSERT' => new DateTime(),
70 'MESSAGE' => $debugInfo,
71 ]);
72 }
73
79 private static function getLevel()
80 {
81 return (int)Option::get('sale', 'pay_system_log_level', static::E_ERROR);
82 }
83
90 public static function add(array $fields)
91 {
92 trigger_error(
93 'Method will be deleted in one of the future releases. Use \Bitrix\Sale\PaySystem\Logger::addError instead',
94 E_USER_WARNING
95 );
96
97 if (isset($fields['ACTION']))
98 {
99 unset($fields['ACTION']);
100 }
101
102 if (isset($fields['MESSAGE'])
103 && is_array($fields['MESSAGE'])
104 )
105 {
106 $fields['MESSAGE'] = implode("\n", $fields['MESSAGE']);
107 }
108
109 $fields['DATE_INSERT'] = new DateTime();
110
111 PaySystemErrLogTable::add($fields);
112 }
113}
static addDebugInfo($debugInfo)
Definition logger.php:56
static addError($error)
Definition logger.php:26
static add(array $fields)
Definition logger.php:90