Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
filelogger.php
1
<?php
2
10
namespace
Bitrix\Main\Diag
;
11
12
class
FileLogger
extends
Logger
13
{
14
protected
$fileName
;
15
protected
$maxSize
= 1048576;
16
21
public
function
__construct
(
string
$fileName
,
int
$maxSize
=
null
)
22
{
23
$this->fileName =
$fileName
;
24
25
if
(
$maxSize
!==
null
)
26
{
27
$this->maxSize =
$maxSize
;
28
}
29
}
30
31
protected
function
logMessage
(
string
$level
,
string
$message
)
32
{
33
$current = ignore_user_abort(
true
);
34
35
if
($fp = fopen($this->fileName,
'ab'
))
36
{
37
if
(flock($fp, LOCK_EX))
38
{
39
// need it for filesize()
40
clearstatcache();
41
$logSize = filesize($this->fileName);
42
43
if
($this->maxSize > 0 && $logSize > $this->maxSize)
44
{
45
$this->
rotateLog
();
46
ftruncate($fp, 0);
47
}
48
49
fwrite($fp,
$message
);
50
fflush($fp);
51
flock($fp, LOCK_UN);
52
}
53
fclose($fp);
54
}
55
56
ignore_user_abort($current);
57
}
58
59
protected
function
rotateLog
()
60
{
61
$historyName = $this->fileName .
'.old'
;
62
63
copy($this->fileName, $historyName);
64
}
65
}
Bitrix\Main\Diag\FileLogger
Definition
filelogger.php:13
Bitrix\Main\Diag\FileLogger\$maxSize
$maxSize
Definition
filelogger.php:15
Bitrix\Main\Diag\FileLogger\logMessage
logMessage(string $level, string $message)
Definition
filelogger.php:31
Bitrix\Main\Diag\FileLogger\$fileName
$fileName
Definition
filelogger.php:14
Bitrix\Main\Diag\FileLogger\__construct
__construct(string $fileName, int $maxSize=null)
Definition
filelogger.php:21
Bitrix\Main\Diag\FileLogger\rotateLog
rotateLog()
Definition
filelogger.php:59
Bitrix\Main\Diag\Logger
Definition
logger.php:19
Bitrix\Main\Diag\Logger\$message
string $message
Definition
logger.php:37
Bitrix\Main\Diag\Logger\$level
$level
Definition
logger.php:31
Bitrix\Main\Diag
Definition
cachetracker.php:2
modules
main
lib
diag
filelogger.php
Создано системой
1.10.0