]> granicus.if.org Git - php/commitdiff
Add a timestamp to the mail log.
authorMartin Jansen <martin@divbyzero.net>
Mon, 24 Dec 2012 10:11:28 +0000 (11:11 +0100)
committerLars Strojny <lstrojny@php.net>
Sun, 6 Jan 2013 14:04:19 +0000 (15:04 +0100)
This patch is loosely based on the one in bug #52126 but instead of
using a UNIX timestamp it uses the date format also being used by
error_log et al.

ext/standard/mail.c

index 25766818f6b50e8ff03edec3c96c12427eab8af6..c8fd55e821d3a70d810729034a145b3cdc50f840 100644 (file)
 #include <stdlib.h>
 #include <ctype.h>
 #include <stdio.h>
+#include <time.h>
 #include "php.h"
 #include "ext/standard/info.h"
 #include "ext/standard/php_string.h"
 #include "ext/standard/basic_functions.h"
+#include "ext/date/php_date.h"
 
 #if HAVE_SYSEXITS_H
 #include <sysexits.h>
@@ -246,8 +248,15 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
        return val;     \
 
        if (mail_log && *mail_log) {
-               char *tmp;
-               int l = spprintf(&tmp, 0, "mail() on [%s:%d]: To: %s -- Headers: %s\n", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : "");
+               char *tmp, *date_str;
+               time_t curtime;
+
+               time(&curtime);
+               date_str = php_format_date("d-M-Y H:i:s e", 13, curtime, 1 TSRMLS_CC);
+
+               int l = spprintf(&tmp, 0, "[%s] mail() on [%s:%d]: To: %s -- Headers: %s\n", date_str, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : "");
+
+               efree(date_str);
 
                if (hdr) {
                        php_mail_log_crlf_to_spaces(tmp);