.sp
.B dmesg \-\-console-level
.I level
+.sp
+.B dmesg \-\-console-on
+.sp
+.B dmesg \-\-console-off
.SH DESCRIPTION
.B dmesg
is used to examine or control the kernel ring buffer.
The default action is to read all messages from kernel ring buffer.
.SH OPTIONS
-The --clear, --read-clear and --console-level options are mutually exclusive.
+The --clear, --read-clear, --console-on, --console-off and --console-level
+options are mutually exclusive.
.IP "\fB\-C, \-\-clear\fP"
Clear the ring buffer.
.IP "\fB\-c, \-\-read-clear\fP"
Clear the ring buffer contents after printing.
+.IP "\fB\-d, \-\-console-off\fP"
+Disable printing messages to the console.
+.IP "\fB\-e, \-\-console-on\fP"
+Enable printing messages to the console.
.IP "\fB\-h, \-\-help\fP"
Print a help text and exit.
.IP "\fB\-n, \-\-console-level \fIlevel\fP
"\nOptions:\n"
" -C, --clear clear the kernel ring buffer\n"
" -c, --read-clear read and clear all messages\n"
+ " -d, --console-off disable printing messages to console\n"
+ " -e, --console-on enable printing messages to console\n"
+ " -h, --help display this help and exit\n"
+ " -n, --console-level=LEVEL set level of messages printed to console\n"
" -r, --raw print the raw message buffer\n"
" -s, --buffer-size=SIZE buffer size to query the kernel ring buffer\n"
- " -n, --console-level=LEVEL set level of messages printed to console\n"
- " -V, --version output version information and exit\n"
- " -h, --help display this help and exit\n\n"));
+ " -V, --version output version information and exit\n\n"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
{ "raw", no_argument, NULL, 'r' },
{ "buffer-size", required_argument, NULL, 's' },
{ "console-level", required_argument, NULL, 'n' },
+ { "console-off", no_argument, NULL, 'd' },
+ { "console-on", no_argument, NULL, 'e' },
{ "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 }
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((c = getopt_long(argc, argv, "Cchrn:s:V", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "Ccdehrn:s:V", longopts, NULL)) != -1) {
- if (cmd != -1 && strchr("Ccn", c))
+ if (cmd != -1 && strchr("Ccnde", c))
errx(EXIT_FAILURE, "%s %s",
- "--{clear,read-clear,console-level}",
+ "--{clear,read-clear,console-level,console-on,console-off}",
_("options are mutually exclusive"));
switch (c) {
case 'c':
cmd = SYSLOG_ACTION_READ_CLEAR;
break;
+ case 'd':
+ cmd = SYSLOG_ACTION_CONSOLE_OFF;
+ break;
+ case 'e':
+ cmd = SYSLOG_ACTION_CONSOLE_ON;
+ break;
case 'n':
cmd = SYSLOG_ACTION_CONSOLE_LEVEL;
console_level = strtol_or_err(optarg,
free(buf);
break;
case SYSLOG_ACTION_CLEAR:
+ case SYSLOG_ACTION_CONSOLE_OFF:
+ case SYSLOG_ACTION_CONSOLE_ON:
n = klogctl(cmd, NULL, 0);
break;
case SYSLOG_ACTION_CONSOLE_LEVEL: