aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2020-05-10 16:46:45 +0200
committern-peugnet <n.peugnet@free.fr>2020-05-11 16:10:08 +0200
commit2f8105cabf63f3ef3d4a59c306f4e1403d3c5164 (patch)
treedf35dfe1e9b883c9b6a7e54d16961ab0df38926d
parentaee12a9f372d839cfbbf3005245b0d691cfdbb4b (diff)
downloadwcms-2f8105cabf63f3ef3d4a59c306f4e1403d3c5164.tar.gz
wcms-2f8105cabf63f3ef3d4a59c306f4e1403d3c5164.zip
fix: log file was not closed
-rw-r--r--app/class/Logger.php8
-rw-r--r--index.php1
-rw-r--r--tests/LoggerTest.php6
3 files changed, 15 insertions, 0 deletions
diff --git a/app/class/Logger.php b/app/class/Logger.php
index e2ab4b6..beceddb 100644
--- a/app/class/Logger.php
+++ b/app/class/Logger.php
@@ -38,6 +38,14 @@ class Logger
self::$verbosity = $verbosity;
}
+ public static function close()
+ {
+ if (self::$file !== false) {
+ fclose(self::$file);
+ self::$file = false;
+ }
+ }
+
protected static function write(string $level, string $msg, array $args = [])
{
$caller = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1];
diff --git a/index.php b/index.php
index 49974f7..bb2adf3 100644
--- a/index.php
+++ b/index.php
@@ -50,3 +50,4 @@ try {
}
echo '<h1>⚠ Whoops ! There is a little problem : </h1>', $e->getMessage(), "\n";
}
+Wcms\Logger::close();
diff --git a/tests/LoggerTest.php b/tests/LoggerTest.php
index eb237ce..5536864 100644
--- a/tests/LoggerTest.php
+++ b/tests/LoggerTest.php
@@ -388,4 +388,10 @@ class LoggerTest extends FilesTest
[4, new Exception('Test 4'), 'Test 4', 0],
];
}
+
+ protected function tearDown(): void
+ {
+ parent::tearDown();
+ Logger::close();
+ }
}