Re: com php-src: Add a timestamp to the mail log.: ext/standard/mail.c
| From: | Pierre Joye | Date: | Sun, 06 Jan 2013 17:20:58 +0000 |
| Subject: | Re: com php-src: Add a timestamp to the mail log.: ext/standard/mail.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-70876@lists.php.net to get a copy of this message | ||
Plesse always put the declaration on top of the current context, l in thus
case.
On Jan 6, 2013 3:14 PM, "Lars Strojny" <lstrojny@php.net> wrote:
> Commit: 4a3bf25e3ffa71d8d65df686c27903d7c9fafee6
> Author: Martin Jansen <martin@divbyzero.net> Mon, 24 Dec 2012
> 11:11:28 +0100
> Committer: Lars Strojny <lstrojny@php.net> Sun, 6 Jan 2013 15:04:19
> +0100
> Parents: 853ef3c9cba5458e403f627103d12351f88ec52f
> Branches: PHP-5.5
>
> Link:
>
> http://git.php.net/?p=php-src.git;a=commitdiff;h=4a3bf25e3ffa71d8d65df686c27903d7c9fafee6
>
> Log:
> Add a timestamp to the mail log.
>
> 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.
>
> Bugs:
> https://bugs.php.net/52126
>
> Changed paths:
> M ext/standard/mail.c
>
>
> Diff:
> diff --git a/ext/standard/mail.c b/ext/standard/mail.c
> index 2576681..c8fd55e 100644
> --- a/ext/standard/mail.c
> +++ b/ext/standard/mail.c
> @@ -21,10 +21,12 @@
> #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);
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>