.B dmesg \-\-help
output.
.IP "\fB\-H\fR, \fB\-\-human\fR"
-Enable human readable output.
+Enable human readable output. See also \fB\-\-color\fR, \fB\-\-reltime\fR
+and \fB\-\-nopager\fR.
.IP "\fB\-h\fR, \fB\-\-help\fR"
Print a help text and exit.
.IP "\fB\-k\fR, \fB\-\-kernel\fR"
will
.I not
print or clear the kernel ring buffer.
+.IP "\fB\-P\fR, \fB\-\-nopager\fR"
+Do not pipe output into a pager, the pager is enabled for \fB\-\-human\fR output.
.IP "\fB\-r\fR, \fB\-\-raw\fR"
Print the raw message buffer, i.e., do not strip the log level prefixes.
#include "closestream.h"
#include "optutils.h"
#include "mangle.h"
+#include "pager.h"
/* Close the log. Currently a NOP. */
#define SYSLOG_ACTION_CLOSE 0
delta:1, /* show time deltas */
reltime:1, /* show human readable relative times */
ctime:1, /* show human readable time */
+ pager:1, /* pipe output into a pager */
color:1; /* colorize messages */
};
fputs(_(" -L, --color colorize messages\n"), out);
fputs(_(" -l, --level <list> restrict output to defined levels\n"), out);
fputs(_(" -n, --console-level <level> set level of messages printed to console\n"), out);
+ fputs(_(" -P, --nopager do not pipe output into a pager\n"), out);
fputs(_(" -r, --raw print the raw message buffer\n"), out);
fputs(_(" -S, --syslog force to use syslog(2) rather than /dev/kmsg\n"), out);
fputs(_(" -s, --buffer-size <size> buffer size to query the kernel ring buffer\n"), out);
int main(int argc, char *argv[])
{
char *buf = NULL;
- int c;
+ int c, nopager = 0;
int console_level = 0;
int klog_rc = 0;
ssize_t n;
{ "show-delta", no_argument, NULL, 'd' },
{ "ctime", no_argument, NULL, 'T' },
{ "notime", no_argument, NULL, 't' },
+ { "nopager", no_argument, NULL, 'P' },
{ "userspace", no_argument, NULL, 'u' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
textdomain(PACKAGE);
atexit(close_stdout);
- while ((c = getopt_long(argc, argv, "CcDdEeF:f:HhkLl:n:rSs:TtuVwx",
+ while ((c = getopt_long(argc, argv, "CcDdEeF:f:HhkLl:n:iPrSs:TtuVwx",
longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
case 'H':
ctl.reltime = 1;
ctl.color = 1;
+ ctl.pager = 1;
break;
case 'h':
usage(stdout);
ctl.action = SYSLOG_ACTION_CONSOLE_LEVEL;
console_level = parse_level(optarg, 0);
break;
+ case 'P':
+ nopager = 1;
+ break;
case 'r':
ctl.raw = 1;
break;
if (!ctl.boot_time)
ctl.reltime = 0;
}
-
if (ctl.color)
ctl.color = colors_init() ? 1 : 0;
+ ctl.pager = nopager ? 0 : ctl.pager;
+ if (ctl.pager)
+ setup_pager();
+
switch (ctl.action) {
case SYSLOG_ACTION_READ_ALL:
case SYSLOG_ACTION_READ_CLEAR:
if (ctl.method == DMESG_METHOD_KMSG && init_kmsg(&ctl) != 0)
ctl.method = DMESG_METHOD_SYSLOG;
-
+ if (ctl.pager)
+ setup_pager();
n = read_buffer(&ctl, &buf);
if (n > 0)
print_buffer(&ctl, buf, n);