rfkill: use human readable timestamps in event output

The event command appears to be something what primarily a developers will
to use when debugging.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2017-06-25 11:33:57 +01:00
parent b3849c66d3
commit 7d0b3acbb4
No known key found for this signature in database
GPG Key ID: A9553245FDE9B739
1 changed files with 11 additions and 4 deletions

View File

@ -31,6 +31,7 @@
#include "optutils.h"
#include "pathnames.h"
#include "strutils.h"
#include "timeutils.h"
#include "widechar.h"
#include "xalloc.h"
@ -135,6 +136,7 @@ static int rfkill_event(void)
{
struct rfkill_event event;
struct timeval tv;
char date_buf[ISO_8601_BUFSIZ];
struct pollfd p;
ssize_t len;
int fd, n, ret = 0;
@ -172,11 +174,16 @@ static int rfkill_event(void)
ret = 1;
continue;
}
gettimeofday(&tv, NULL);
printf("%ld.%06u: idx %u type %u op %u soft %u hard %u\n",
(long) tv.tv_sec, (unsigned int) tv.tv_usec,
event.idx, event.type, event.op, event.soft, event.hard);
strtimeval_iso(&tv,
ISO_8601_DATE |
ISO_8601_TIME |
ISO_8601_COMMAUSEC |
ISO_8601_TIMEZONE |
ISO_8601_SPACE, date_buf, sizeof(date_buf));
printf("%s: idx %u type %u op %u soft %u hard %u\n",
date_buf,
event.idx, event.type, event.op, event.soft, event.hard);
fflush(stdout);
}