We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to print log with current time in this way:
uint64_t now = tmr_seconds(); DEBUG_WARNING("time:%llu, statistics ok\n");
static uint64_t tmr_seconds(void) { struct timeval now; uint64_t usec; if (0 != gettimeofday(&now, NULL)) { DEBUG_WARNING("jiffies: gettimeofday() failed (%m)\n", errno); return 0; } usec = (uint64_t)now.tv_sec; return usec; }
Are there other more elegant ways? Thank you
The text was updated successfully, but these errors were encountered:
check out the DBG_TIME option in dbg_init:
DBG_TIME
/** Debug flags */ enum dbg_flags { DBG_NONE = 0, /**< No debug flags */ DBG_TIME = 1<<0, /**< Print timestamp flag */ DBG_ANSI = 1<<1, /**< Print ANSI color codes */ DBG_ALL = DBG_TIME|DBG_ANSI /**< All flags enabled */ }; void dbg_init(int level, enum dbg_flags flags);
If you enable DBG_TIME it will prefix all loglines with the timestamp.
Alfred
Sorry, something went wrong.
I set the options withe dbg_init: dbg_init(DBG_DEBUG, DBG_ALL);
dbg_init(DBG_DEBUG, DBG_ALL);
I think this time is program running time, not system time.
Thank you.
for questions about how to use the API it is better to use the mailing list:
http://lists.creytiv.com/mailman/listinfo/re-devel
here is a simple test program using fmt_gmtime and fmt_human_time
fmt_gmtime
fmt_human_time
#include <re.h> int main(void) { uint32_t seconds = 3600 + 60 + 5; re_printf("gmtime: %H\n", fmt_gmtime, NULL); re_printf("human_time: %H\n", fmt_human_time, &seconds); }
and the output:
./test gmtime: Thu, 05 Apr 2018 06:48:48 GMT human_time: 1 hour 1 min 5 secs
No branches or pull requests
I want to print log with current time in this way:
Are there other more elegant ways?
Thank you
The text was updated successfully, but these errors were encountered: