mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 22:13:01 +07:00
Use relative timestamp
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
+15
-1
@@ -133,18 +133,28 @@ static int debug = 0;
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
static struct timeval t0;
|
||||
|
||||
void _d(char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
struct timeval t;
|
||||
int s, ms;
|
||||
|
||||
if (!debug)
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
s = t.tv_sec - t0.tv_sec;
|
||||
ms = (t.tv_usec - t0.tv_usec) / 1000;
|
||||
if (ms < 0) {
|
||||
ms += 1000;
|
||||
s -= 1;
|
||||
}
|
||||
|
||||
gettimeofday(&t, NULL);
|
||||
printf("[%ld.%03ld] ", t.tv_sec, t.tv_usec / 1000);
|
||||
printf("[%ld.%03ld] ", s, ms);
|
||||
vprintf(fmt, ap);
|
||||
printf("\n");
|
||||
va_end(ap);
|
||||
@@ -233,6 +243,10 @@ int main()
|
||||
struct utmp entry;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_TIMESTAMP
|
||||
gettimeofday(&t0, NULL);
|
||||
#endif
|
||||
|
||||
puts("finit-alt " VERSION " (built " __DATE__ " " __TIME__
|
||||
" by " WHOAMI ")");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user