diff options
Diffstat (limited to 'src/sys/os/os_syslog.c')
-rw-r--r-- | src/sys/os/os_syslog.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/sys/os/os_syslog.c b/src/sys/os/os_syslog.c index b0e07dc..b6d30b7 100644 --- a/src/sys/os/os_syslog.c +++ b/src/sys/os/os_syslog.c @@ -30,10 +30,18 @@ #include <sys/types.h> #include <machine/uart.h> /* shared */ #include <sys/syslog.h> +#include <io/cons/cons.h> #include <os/spinlock.h> #include <string.h> #include <stdarg.h> +/* + * If this value is true, data will be written to + * the video console, otherwise only serial logging + * will be used. + */ +static bool cons_enabled = false; + static void syslog_write(const char *str, size_t len) { @@ -41,6 +49,8 @@ syslog_write(const char *str, size_t len) spinlock_acquire(&lock); for (int i = 0; i < len; ++i) { + if (cons_enabled) + cons_putstr(&g_root_scr, str, 1); uart_write(*str++); } spinlock_release(&lock); @@ -64,3 +74,9 @@ printf(const char *fmt, ...) vprintf(fmt, &ap); va_end(ap); } + +void +syslog_toggle(bool enable) +{ + cons_enabled = enable; +} |