summaryrefslogtreecommitdiff
path: root/sys/kern/kern_syslog.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_syslog.c')
-rw-r--r--sys/kern/kern_syslog.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/sys/kern/kern_syslog.c b/sys/kern/kern_syslog.c
index 656362e..db50a3c 100644
--- a/sys/kern/kern_syslog.c
+++ b/sys/kern/kern_syslog.c
@@ -40,8 +40,15 @@
#define SERIAL_DEBUG 0
#endif
+#if defined(__USER_KMSG)
+#define USER_KMSG __USER_KMSG
+#else
+#define USER_KMSG 0
+#endif
+
/* Global logger lock */
static struct spinlock lock = {0};
+static bool no_cons_log = false;
static void
syslog_write(const char *s, size_t len)
@@ -58,6 +65,15 @@ syslog_write(const char *s, size_t len)
}
}
+ /*
+ * If the USER_KMSG option is disabled in kconf,
+ * do not log to the console if everything else
+ * has already started.
+ */
+ if (!USER_KMSG && no_cons_log) {
+ return;
+ }
+
cons_putstr(&g_root_scr, s, len);
}
@@ -116,3 +132,16 @@ kprintf(const char *fmt, ...)
va_end(ap);
spinlock_release(&lock);
}
+
+/*
+ * Silence kernel messages in if the system
+ * is already operating in a user context.
+ *
+ * XXX: This is ignored if the kconf USER_KMSG
+ * option is set to "no"
+ */
+void
+syslog_silence(bool option)
+{
+ no_cons_log = option;
+}