Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
logger.php
1
<?php
2
3
namespace
Bitrix\Sale\PaySystem
;
4
5
use
Bitrix\Main\ArgumentTypeException
;
6
use
Bitrix\Main\Config\Option
;
7
use
Bitrix\Main\Type\DateTime
;
8
use
Bitrix\Sale\Internals\PaySystemErrLogTable
;
9
14
class
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
}
Bitrix\Main\ArgumentTypeException
Definition
exception.php:114
Bitrix\Main\Config\Option
Definition
option.php:15
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Sale\Cashbox\Logger
Definition
logger.php:15
Bitrix\Sale\Internals\PaySystemErrLogTable
Definition
paysystemerrlog.php:32
Bitrix\Sale\PaySystem\Logger\addDebugInfo
static addDebugInfo($debugInfo)
Definition
logger.php:56
Bitrix\Sale\PaySystem\Logger\E_ALL
const E_ALL
Definition
logger.php:16
Bitrix\Sale\PaySystem\Logger\addError
static addError($error)
Definition
logger.php:26
Bitrix\Sale\PaySystem\Logger\E_ERROR
const E_ERROR
Definition
logger.php:17
Bitrix\Sale\PaySystem\Logger\add
static add(array $fields)
Definition
logger.php:90
Bitrix\Sale\PaySystem
Definition
applepay.php:3
modules
sale
lib
paysystem
logger.php
Создано системой
1.10.0