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