From dc9b8315348233dc86b06655f9630ebeaa736525 Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 13 Jan 2025 13:24:38 -0500 Subject: [PATCH] Fixed FileLogging issue by setting the write permission to 0666 for the log file if it doesn't exist. --- CHANGELOG.md | 9 +++++++++ project.json | 2 +- src/LogLib/Classes/FileLock.php | 7 +++++-- src/LogLib/Handlers/FileLogging.php | 6 ------ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bd4d78..f5383a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.7] - 2025-01-13 + +This update introduces a minor fix + +### Fixed + - Fixed FileLogging issue by setting the write permission to 0666 for the log file if it doesn't exist. + + + ## [2.0.6] - 2025-01-10 This update introduces a minor change diff --git a/project.json b/project.json index 947fc02..f82416d 100644 --- a/project.json +++ b/project.json @@ -20,7 +20,7 @@ "package": "net.nosial.loglib", "company": "Nosial", "copyright": "Copyright (c) 2022-2023 Nosial", - "version": "2.0.6", + "version": "2.0.7", "uuid": "de1deca6-7b65-11ed-a8b0-a172264634d8" }, "build": { diff --git a/src/LogLib/Classes/FileLock.php b/src/LogLib/Classes/FileLock.php index 692cf24..dd34fb6 100644 --- a/src/LogLib/Classes/FileLock.php +++ b/src/LogLib/Classes/FileLock.php @@ -32,8 +32,11 @@ // Create the file if it doesn't exist if (!file_exists($filePath)) { - $this->fileHandle = fopen($filePath, 'w'); - fclose($this->fileHandle); + // Create the file + touch($filePath); + + // Set the file permissions to 0666 + chmod($filePath, 0666); } } diff --git a/src/LogLib/Handlers/FileLogging.php b/src/LogLib/Handlers/FileLogging.php index d8548b0..75234b5 100644 --- a/src/LogLib/Handlers/FileLogging.php +++ b/src/LogLib/Handlers/FileLogging.php @@ -21,12 +21,6 @@ class FileLogging implements LogHandlerInterface */ public static function handle(Application $application, Event $event): void { - // If we're running in a Web environment, return - if(!Utilities::runningInCli()) - { - return; - } - if(!Validate::checkLevelType($event->getLevel(), $application->getFileLoggingLevel())) { return;