[PATCH 2/3] Log: Remove date from timestamp, log it only once.
Pekka Paalanen
ppaalanen at gmail.com
Mon Jun 11 03:57:16 PDT 2012
Hi Martin,
this is a good series, and I'm already working based on this. I think
this can go in as is, though I do want point out one thing.
On Mon, 11 Jun 2012 01:00:23 +0200
Martin Minarik <minarik11 at student.fiit.stuba.sk> wrote:
> This patch may be useful, the timestamp with date seems too long.
> ---
> src/log.c | 13 ++++++++++++-
> 1 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/src/log.c b/src/log.c
> index a111cf8..0452e65 100644
> --- a/src/log.c
> +++ b/src/log.c
> @@ -34,6 +34,8 @@
>
> static FILE *weston_logfile = NULL;
>
> +static int cached_tm_mday = -1;
> +
> static int weston_log_timestamp(void)
> {
> struct timeval tv;
> @@ -44,7 +46,16 @@ static int weston_log_timestamp(void)
>
> brokendown_time = localtime(&tv.tv_sec);
>
> - strftime(string, sizeof string, "%Y-%m-%d %H:%M:%S", brokendown_time);
> + strftime(string, sizeof string, "%H:%M:%S", brokendown_time);
> +
> + if (brokendown_time->tm_mday != cached_tm_mday) {
What if the day is the same, but month different? Or year.
Ok, the probability of that happening is tiny, the consequences are
negligible even if it did happen, and it is trivial to fix at any time
later, so no problem.
> + char date_string[128];
> +
> + strftime(date_string, sizeof string, "%Y-%m-%d %Z", brokendown_time);
> + fprintf(weston_logfile, "Date: %s\n", date_string);
> +
> + cached_tm_mday = brokendown_time->tm_mday;
> + }
>
> return fprintf(weston_logfile, "[%s.%03li] ", string, tv.tv_usec/1000);
> }
Thanks,
pq
More information about the wayland-devel
mailing list