Skip to content

Commit

Permalink
Microseconds to errorlog, small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhainin committed Nov 25, 2022
1 parent 0ec472a commit d59a6a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
3 changes: 1 addition & 2 deletions ext/date/php_date.c
Expand Up @@ -814,7 +814,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, bool localtime)
}
/* }}} */

PHPAPI zend_string *php_format_timestamp(const char *format, size_t format_len, time_t ts, suseconds_t usec, bool localtime) /* {{{ */
PHPAPI zend_string *php_format_timestamp(const char *format, size_t format_len, time_t ts, suseconds_t usec, bool localtime)
{
timelib_time *t;
timelib_tzinfo *tzi;
Expand All @@ -839,7 +839,6 @@ PHPAPI zend_string *php_format_timestamp(const char *format, size_t format_len,
timelib_time_dtor(t);
return string;
}
/* }}} */

PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, bool localtime) /* {{{ */
{
Expand Down
4 changes: 2 additions & 2 deletions main/main.c
Expand Up @@ -834,13 +834,13 @@ PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int sys
suseconds_t error_time_usec = 0;

const char *error_log_format = "d-M-Y H:i:s e";
size_t error_log_format_len = sizeof("d-M-Y H:i:s e") - 1;

if (PG(error_log_usec)) {
error_log_format = "d-M-Y H:i:s.u e";
error_log_format_len = sizeof("d-M-Y H:i:s.u e") - 1;
}

size_t error_log_format_len = strlen(error_log_format);

#if HAVE_GETTIMEOFDAY
struct timeval tp = {0}; /* For setting microseconds */

Expand Down
33 changes: 13 additions & 20 deletions tests/basic/errorlog_usec.phpt
@@ -1,35 +1,28 @@
--TEST--
Check permissions for created errorlog file
--SKIPIF--
<?php
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
die("skip this test on windows");
}
Microseconds in error log file
?>
--INI--
error_log=error_usec_test.log
error_log_usec=On
--FILE--
<?php

const LOG_FILENAME='error_usec_test.log';
define('LOG_FILENAME', ini_get("error_log"));

try {
if (file_exists(LOG_FILENAME)) {
unlink(LOG_FILENAME);
}
$oldMask = umask(0000);
if (file_exists(LOG_FILENAME)) {
unlink(LOG_FILENAME);
}

error_log("hello world");
error_log("hello world");

assert(file_exists(LOG_FILENAME));
assert(file_exists(LOG_FILENAME));

printf("errorlog contents\n%s", file_get_contents(LOG_FILENAME));
umask($oldMask);
} finally {
unlink(LOG_FILENAME);
}
printf("errorlog contents\n%s", file_get_contents(LOG_FILENAME));

?>
--CLEAN--
<?php
unlink(LOG_FILENAME);
?>
--EXPECTF--
errorlog contents
Expand Down

0 comments on commit d59a6a3

Please sign in to comment.