From: Stephen Hemminger <stephen@networkplumber.org>
To: Vadim Kochan <vadim4j@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] ip lib: Change timestamp to be shorter and on the same line
Date: Tue, 16 Sep 2014 19:38:50 -0700 [thread overview]
Message-ID: <20140916193850.4dec41e8@urahara> (raw)
In-Reply-To: <1410861486-2631-1-git-send-email-vadim4j@gmail.com>
On Tue, 16 Sep 2014 12:58:06 +0300
Vadim Kochan <vadim4j@gmail.com> wrote:
> Changed timestamp format to look like more logging info:
>
> [Sep 01 20:56:11.853146]2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default
> link/ether 3c:97:0e:a3:86:2e brd ff:ff:ff:ff:ff:ff
>
> Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
> ---
> lib/utils.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/lib/utils.c b/lib/utils.c
> index dc21567..03092ba 100644
> --- a/lib/utils.c
> +++ b/lib/utils.c
> @@ -772,14 +772,13 @@ __u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
> int print_timestamp(FILE *fp)
> {
> struct timeval tv;
> - char *tstr;
> + char tstr[40] = {};
>
> memset(&tv, 0, sizeof(tv));
> gettimeofday(&tv, NULL);
>
> - tstr = asctime(localtime(&tv.tv_sec));
> - tstr[strlen(tstr)-1] = 0;
> - fprintf(fp, "Timestamp: %s %ld usec\n", tstr, (long)tv.tv_usec);
> + strftime(tstr, sizeof(tstr), "%b %d %H:%M:%S", localtime(&tv.tv_sec));
> + fprintf(fp, "[%s.%ld]", tstr, (long)tv.tv_usec);
> return 0;
> }
>
I am loath to change the output format since people write scripts parsing
output. Maybe add a new flag option to choose format?
next prev parent reply other threads:[~2014-09-17 2:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 9:58 [PATCH iproute2] ip lib: Change timestamp to be shorter and on the same line Vadim Kochan
2014-09-17 2:38 ` Stephen Hemminger [this message]
2014-09-17 6:06 ` Vadim Kochan
2014-10-10 11:27 ` Vadim Kochan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140916193850.4dec41e8@urahara \
--to=stephen@networkplumber.org \
--cc=netdev@vger.kernel.org \
--cc=vadim4j@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox