1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
fileexceptionhandlerlog.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Diag;
4
5
use Bitrix\Main;
6
use Psr\Log;
7
8
class
FileExceptionHandlerLog
extends
ExceptionHandlerLog
9
{
10
const
MAX_LOG_SIZE
= 1000000;
11
const
DEFAULT_LOG_FILE
=
"bitrix/modules/error.log"
;
12
13
private
$level;
14
16
protected
$logger
;
17
18
public
function
initialize
(
array
$options
)
19
{
20
$logFile = static::DEFAULT_LOG_FILE;
21
if
(isset(
$options
[
"file"
]) && !empty(
$options
[
"file"
]))
22
{
23
$logFile =
$options
[
"file"
];
24
}
25
26
if
((!str_starts_with($logFile,
"/"
)) && !preg_match(
"#^[a-z]:/#"
, $logFile))
27
{
28
$logFile =
Main\Application::getDocumentRoot
().
"/"
.$logFile;
29
}
30
31
$maxLogSize = static::MAX_LOG_SIZE;
32
if
(isset(
$options
[
"log_size"
]) &&
$options
[
"log_size"
] > 0)
33
{
34
$maxLogSize = (int)
$options
[
"log_size"
];
35
}
36
37
$this->logger =
new
FileLogger
($logFile, $maxLogSize);
38
39
if
(isset(
$options
[
"level"
]) &&
$options
[
"level"
] > 0)
40
{
41
$this->level = (int)
$options
[
"level"
];
42
}
43
}
44
49
public
function
write
($exception, $logType)
50
{
51
$text
=
ExceptionHandlerFormatter::format
($exception,
false
, $this->level);
52
53
$context
= [
54
'type'
=> static::logTypeToString($logType),
55
];
56
57
$logLevel = static::logTypeToLevel($logType);
58
59
$message
=
"{date} - Host: {host} - {type} - {$text}\n"
;
60
61
$this->logger->log($logLevel,
$message
,
$context
);
62
}
63
67
protected
function
writeToLog
(
$text
)
68
{
69
$this->logger->debug(
$text
);
70
}
71
}
Bitrix\Main\Application\getDocumentRoot
static getDocumentRoot()
Определения
application.php:736
Bitrix\Main\Diag\ExceptionHandlerFormatter\format
static format($exception, $htmlMode=false, $level=0)
Определения
exceptionhandlerformatter.php:20
Bitrix\Main\Diag\ExceptionHandlerLog
Определения
exceptionhandlerlog.php:8
Bitrix\Main\Diag\FileExceptionHandlerLog
Определения
fileexceptionhandlerlog.php:9
Bitrix\Main\Diag\FileExceptionHandlerLog\DEFAULT_LOG_FILE
const DEFAULT_LOG_FILE
Определения
fileexceptionhandlerlog.php:11
Bitrix\Main\Diag\FileExceptionHandlerLog\write
write($exception, $logType)
Определения
fileexceptionhandlerlog.php:49
Bitrix\Main\Diag\FileExceptionHandlerLog\initialize
initialize(array $options)
Определения
fileexceptionhandlerlog.php:18
Bitrix\Main\Diag\FileExceptionHandlerLog\MAX_LOG_SIZE
const MAX_LOG_SIZE
Определения
fileexceptionhandlerlog.php:10
Bitrix\Main\Diag\FileExceptionHandlerLog\writeToLog
writeToLog($text)
Определения
fileexceptionhandlerlog.php:67
Bitrix\Main\Diag\FileExceptionHandlerLog\$logger
$logger
Определения
fileexceptionhandlerlog.php:16
Bitrix\Main\Diag\FileLogger
Определения
filelogger.php:13
$options
$options
Определения
commerceml2.php:49
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$context
$context
Определения
csv_new_setup.php:223
$message
$message
Определения
payment.php:8
$text
$text
Определения
template_pdf.php:79
bitrix
modules
main
lib
diag
fileexceptionhandlerlog.php
Создано системой
1.14.0