aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_syslog.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/kern/kern_syslog.c b/sys/kern/kern_syslog.c
index 5b009e7..6962a69 100644
--- a/sys/kern/kern_syslog.c
+++ b/sys/kern/kern_syslog.c
@@ -30,6 +30,7 @@
#include <sys/syslog.h>
#include <sys/spinlock.h>
#include <dev/cons/cons.h>
+#include <dev/timer.h>
#include <stdarg.h>
#include <string.h>
@@ -66,6 +67,8 @@ kprintf(const char *fmt, ...)
char timestamp[64] = "[ 0.000000] ";
const char *fmt_p = fmt;
bool use_timestamp = true;
+ bool has_counter = true;
+ struct timer tmr;
/*
* If the first char is OMIT_TIMESTAMP, then we won't
@@ -76,6 +79,19 @@ kprintf(const char *fmt, ...)
use_timestamp = false;
}
+ /* See if we have a timer */
+ if (req_timer(TIMER_GP, &tmr) != TMRR_SUCCESS) {
+ has_counter = false;
+ }
+
+ /* If we can use the counter, format the timestamp */
+ if (has_counter) {
+ if (tmr.get_time_sec != NULL && tmr.get_time_usec != NULL) {
+ snprintf(timestamp, sizeof(timestamp), "[ %d.%06d] ",
+ tmr.get_time_sec(), tmr.get_time_usec());
+ }
+ }
+
if (use_timestamp) {
syslog_write(timestamp, strlen(timestamp));
}