diff options
-rw-r--r-- | kern/log.c | 9 | ||||
-rw-r--r-- | kern/log.h | 6 |
2 files changed, 14 insertions, 1 deletions
@@ -22,6 +22,7 @@ #include <stddef.h> #include <stdio.h> #include <stdint.h> +#include <string.h> #include <kern/cbuf.h> #include <kern/init.h> @@ -457,6 +458,7 @@ log_vmsg(unsigned int level, const char *format, va_list ap) unsigned long flags; int nr_chars; size_t size; + char *ptr; log_record_init_produce(&record, level); nr_chars = vsnprintf(record.buffer, sizeof(record.buffer), format, ap); @@ -466,6 +468,13 @@ log_vmsg(unsigned int level, const char *format, va_list ap) goto out; } + ptr = strchr(record.buffer, '\n'); + + if (ptr != NULL) { + *ptr = '\0'; + nr_chars = ptr - record.buffer; + } + assert(nr_chars >= 0); size = offsetof(struct log_record, buffer) + nr_chars + 1; @@ -48,7 +48,11 @@ void log_start(void); /* * Generate a message and send it to the log thread. * - * Except for level, the arguments and return value are similar to printf(). + * The arguments and return value are similar to printf(), with + * these exceptions : + * - a level is associated to each log message + * - processing stops at the first terminating null byte or newline + * character, whichever occurs first * * This function may safely be called in interrupt context. */ |