mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
log handler fix
This commit is contained in:
@@ -34,7 +34,10 @@ use Monolog\{
|
||||
Handler\StreamHandler as MonologStreamHandler,
|
||||
};
|
||||
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\{
|
||||
Utils\File\Manager as FileManager,
|
||||
Utils\Config,
|
||||
};
|
||||
|
||||
use LogicException;
|
||||
use UnexpectedValueException;
|
||||
@@ -45,19 +48,11 @@ class EspoFileHandler extends MonologStreamHandler
|
||||
|
||||
protected $maxErrorMessageLength = 5000;
|
||||
|
||||
protected $configPath = 'data/config.php';
|
||||
|
||||
public function __construct(string $filename, $level = Logger::DEBUG, bool $bubble = true)
|
||||
public function __construct(string $filename, $level = Logger::DEBUG, bool $bubble = true, Config $config)
|
||||
{
|
||||
parent::__construct($filename, $level, $bubble);
|
||||
|
||||
$defaultPermissions = null;
|
||||
|
||||
if (file_exists($this->configPath)) {
|
||||
$configData = include $this->configPath;
|
||||
|
||||
$defaultPermissions = $configData['defaultPermissions'] ?? null;
|
||||
}
|
||||
$defaultPermissions = $config->get('defaultPermissions');
|
||||
|
||||
$this->fileManager = new FileManager($defaultPermissions);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ namespace Espo\Core\Log\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\Config,
|
||||
};
|
||||
|
||||
class EspoRotatingFileHandler extends EspoFileHandler
|
||||
{
|
||||
protected $dateFormat = 'Y-m-d';
|
||||
@@ -41,12 +45,13 @@ class EspoRotatingFileHandler extends EspoFileHandler
|
||||
|
||||
protected $maxFiles;
|
||||
|
||||
public function __construct(string $filename, int $maxFiles = 0, $level = Logger::DEBUG, bool $bubble = true)
|
||||
{
|
||||
public function __construct(
|
||||
string $filename, int $maxFiles = 0, $level = Logger::DEBUG, bool $bubble = true, Config $config
|
||||
) {
|
||||
$this->filename = $filename;
|
||||
$this->maxFiles = (int) $maxFiles;
|
||||
|
||||
parent::__construct($this->getTimedFilename(), $level, $bubble);
|
||||
parent::__construct($this->getTimedFilename(), $level, $bubble, $config);
|
||||
|
||||
$this->rotate();
|
||||
}
|
||||
|
||||
@@ -108,9 +108,10 @@ class LogLoader
|
||||
if ($rotation) {
|
||||
$maxFileNumber = $this->config->get('logger.maxFileNumber') ?? self::MAX_FILE_NUMBER;
|
||||
|
||||
$handler = new EspoRotatingFileHandler($path, $maxFileNumber, $levelCode);
|
||||
} else {
|
||||
$handler = new EspoFileHandler($path, $levelCode);
|
||||
$handler = new EspoRotatingFileHandler($path, $maxFileNumber, $levelCode, true, $this->config);
|
||||
}
|
||||
else {
|
||||
$handler = new EspoFileHandler($path, $levelCode, true, $this->config);
|
||||
}
|
||||
|
||||
$formatter = new LineFormatter(
|
||||
|
||||
Reference in New Issue
Block a user