Print a help text and exit.
.IP "\fB\-k\fR, \fB\-\-kernel\fR"
Print kernel messages.
-.IP "\fB\-L\fR, \fB\-\-color\fR"
-Colorize important messages.
+.IP "\fB\-L\fR, \fB\-\-color\fR [=\fIwhen\fP]"
+Colorize important messages, the optional argumet \fIwhen\fP is 'auto', 'never'
+or 'always'. If the \fIwhen\fP argument is omitted then the default is 'auto'.
.IP "\fB\-l\fR, \fB\-\-level \fIlist\fR"
Restrict output to defined (comma separated)
.I list
fputs(_(" -f, --facility <list> restrict output to defined facilities\n"), out);
fputs(_(" -H, --human human readable output\n"), out);
fputs(_(" -k, --kernel display kernel messages\n"), out);
- fputs(_(" -L, --color colorize messages\n"), out);
+ fputs(_(" -L, --color[=<when>] colorize messages (auto, always or never)\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);
.method = DMESG_METHOD_KMSG,
.kmsg = -1,
};
+ int colormode = UL_COLORMODE_NEVER;
static const struct option longopts[] = {
{ "buffer-size", required_argument, NULL, 's' },
{ "clear", no_argument, NULL, 'C' },
- { "color", no_argument, NULL, 'L' },
+ { "color", optional_argument, NULL, 'L' },
{ "console-level", required_argument, NULL, 'n' },
{ "console-off", no_argument, NULL, 'D' },
{ "console-on", no_argument, NULL, 'E' },
textdomain(PACKAGE);
atexit(close_stdout);
- while ((c = getopt_long(argc, argv, "CcDdEeF:f:HhkLl:n:iPrSs:TtuVwx",
+ while ((c = getopt_long(argc, argv, "CcDdEeF:f:HhkL::l:n:iPrSs:TtuVwx",
longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
setbit(ctl.facilities, FAC_BASE(LOG_KERN));
break;
case 'L':
- ctl.color = 1;
+ colormode = UL_COLORMODE_AUTO;
+ if (optarg) {
+ char *p = *optarg == '=' ? optarg + 1 : optarg;
+ colormode = colormode_from_string(p);
+ if (colormode < 0)
+ errx(EXIT_FAILURE, _("unsupported color mode: '%s'"), p);
+ }
break;
case 'l':
ctl.fltr_lev= 1;
if (!ctl.boot_time)
ctl.reltime = 0;
}
- if (ctl.color)
- ctl.color = colors_init() ? 1 : 0;
+
+ ctl.color = colors_init(colormode) ? 1 : 0;
ctl.pager = nopager ? 0 : ctl.pager;
if (ctl.pager)