Skip to content

Commit

Permalink
Merge pull request #92 from MarcelBolten/__c3_error_log
Browse files Browse the repository at this point in the history
Give the error log file a chance to be created
  • Loading branch information
Naktibalda authored Dec 1, 2023
2 parents d578d44 + 5d1c659 commit 3ded67e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions c3.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
if ($cookie) {
foreach ($cookie as $key => $value) {
if (!empty($value)) {
$_SERVER["HTTP_X_CODECEPTION_" . strtoupper($key)] = $value;
$_SERVER['HTTP_X_CODECEPTION_' . strtoupper($key)] = $value;
}
}
}
Expand All @@ -43,9 +43,7 @@ function __c3_error($message)
$errorLogFile = defined('C3_CODECOVERAGE_ERROR_LOG_FILE') ?
C3_CODECOVERAGE_ERROR_LOG_FILE :
C3_CODECOVERAGE_MEDIATE_STORAGE . DIRECTORY_SEPARATOR . 'error.txt';
if (is_writable($errorLogFile)) {
file_put_contents($errorLogFile, $message);
} else {
if (file_put_contents($errorLogFile, $message, FILE_APPEND | LOCK_EX) === false) {
$message = "Could not write error to log file ($errorLogFile), original message: $message";
}
if (!headers_sent()) {
Expand Down Expand Up @@ -177,7 +175,7 @@ function __c3_build_crap4j_report(PHP_CodeCoverage $codeCoverage, $path)
function __c3_build_cobertura_report(PHP_CodeCoverage $codeCoverage, $path)
{
if (!class_exists(\SebastianBergmann\CodeCoverage\Report\Cobertura::class)) {
throw new Exception("Cobertura report requires php-code-coverage >= 9.2");
throw new Exception('Cobertura report requires php-code-coverage >= 9.2');
}
$writer = new \SebastianBergmann\CodeCoverage\Report\Cobertura();
$writer->process($codeCoverage, $path . '.cobertura.xml');
Expand Down

0 comments on commit 3ded67e

Please sign in to comment.