diff --git a/CHANGELOG.md b/CHANGELOG.md index bfc10d1..9bd4d78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ 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.6] - 2025-01-10 + +This update introduces a minor change + +### Changed + - File logging is disabled for web environments due to instability in file locking, until a better solution is found. + + ## [2.0.5] - 2025-01-09 This update introduces a minor bug fix diff --git a/src/LogLib/Handlers/ConsoleLogging.php b/src/LogLib/Handlers/ConsoleLogging.php index 97b683d..54fb3bc 100644 --- a/src/LogLib/Handlers/ConsoleLogging.php +++ b/src/LogLib/Handlers/ConsoleLogging.php @@ -24,7 +24,6 @@ class ConsoleLogging implements LogHandlerInterface */ public static function handle(Application $application, Event $event): void { - // Check if the application is running in a CLI environment, if not, return if(!Utilities::runningInCli()) { return; diff --git a/src/LogLib/Handlers/FileLogging.php b/src/LogLib/Handlers/FileLogging.php index b8682b6..d8548b0 100644 --- a/src/LogLib/Handlers/FileLogging.php +++ b/src/LogLib/Handlers/FileLogging.php @@ -21,6 +21,12 @@ 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; @@ -88,9 +94,9 @@ class FileLogging implements LogHandlerInterface $logging_file = $logging_directory . DIRECTORY_SEPARATOR . Utilities::sanitizeFileName($application->getApplicationName()) . '-' . date('Y-m-d') . '.log'; - if(!file_exists($logging_file)) + if(!file_exists($logging_file) && !@touch($logging_file)) { - touch($logging_file); + throw new RuntimeException(sprintf("Cannot write to %s due to insufficient permissions", $logging_file)); } return $logging_file;