mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-20 11:35:42 +02:00
parent
7d3851046e
commit
be10465a3b
4 changed files with 34 additions and 10 deletions
|
@ -18,6 +18,8 @@
|
||||||
four borders to the same value
|
four borders to the same value
|
||||||
(https://codeberg.org/dnkl/yambar/issues/77).
|
(https://codeberg.org/dnkl/yambar/issues/77).
|
||||||
* river: `per-output: false|true`.
|
* river: `per-output: false|true`.
|
||||||
|
* `-d,--log-level=info|warning|error|none` command line option
|
||||||
|
(https://codeberg.org/dnkl/yambar/issues/84).
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -8,5 +8,6 @@ _arguments \
|
||||||
'(-c --config)'{-c,--config}'[alternative configuration file]:filename:_files' \
|
'(-c --config)'{-c,--config}'[alternative configuration file]:filename:_files' \
|
||||||
'(-C --validate)'{-C,--validate}'[verify configuration then quit]' \
|
'(-C --validate)'{-C,--validate}'[verify configuration then quit]' \
|
||||||
'(-p --print-pid)'{-p,--print-pid}'[print PID to this file or FD when up and running]:pidfile:_files' \
|
'(-p --print-pid)'{-p,--print-pid}'[print PID to this file or FD when up and running]:pidfile:_files' \
|
||||||
|
'(-d --log-level)'{-d,--log-level}'[log level (info)]:loglevel:(info warning error none)' \
|
||||||
'(-l --log-colorize)'{-l,--log-colorize}'[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \
|
'(-l --log-colorize)'{-l,--log-colorize}'[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \
|
||||||
'(-s --log-no-syslog)'{-s,--log-no-syslog}'[disable syslog logging]'
|
'(-s --log-no-syslog)'{-s,--log-no-syslog}'[disable syslog logging]'
|
||||||
|
|
|
@ -27,6 +27,10 @@ yambar - modular status panel for X11 and Wayland
|
||||||
(or FD) is closed immediately after writing the PID. When a _FILE_
|
(or FD) is closed immediately after writing the PID. When a _FILE_
|
||||||
as been specified, the file is unlinked exit.
|
as been specified, the file is unlinked exit.
|
||||||
|
|
||||||
|
*-d*,*--log-level*={*info*,*warning*,*error*,*none*}
|
||||||
|
Log level, used both for log output on stderr as well as
|
||||||
|
syslog. Default: _info_.
|
||||||
|
|
||||||
*-l*,*--log-colorize*=[{*never*,*always*,*auto*}]
|
*-l*,*--log-colorize*=[{*never*,*always*,*auto*}]
|
||||||
Enables or disables colorization of log output on stderr.
|
Enables or disables colorization of log output on stderr.
|
||||||
|
|
||||||
|
|
23
main.c
23
main.c
|
@ -131,6 +131,7 @@ print_usage(const char *prog_name)
|
||||||
" -c,--config=FILE alternative configuration file\n"
|
" -c,--config=FILE alternative configuration file\n"
|
||||||
" -C,--validate verify configuration then quit\n"
|
" -C,--validate verify configuration then quit\n"
|
||||||
" -p,--print-pid=FILE|FD print PID to file or FD\n"
|
" -p,--print-pid=FILE|FD print PID to file or FD\n"
|
||||||
|
" -d,--log-level={info|warning|error|none} log level (info)\n"
|
||||||
" -l,--log-colorize=[never|always|auto] enable/disable colorization of log output on stderr\n"
|
" -l,--log-colorize=[never|always|auto] enable/disable colorization of log output on stderr\n"
|
||||||
" -s,--log-no-syslog disable syslog logging\n"
|
" -s,--log-no-syslog disable syslog logging\n"
|
||||||
" -v,--version show the version number and quit\n");
|
" -v,--version show the version number and quit\n");
|
||||||
|
@ -181,6 +182,7 @@ main(int argc, char *const *argv)
|
||||||
{"config", required_argument, 0, 'c'},
|
{"config", required_argument, 0, 'c'},
|
||||||
{"validate", no_argument, 0, 'C'},
|
{"validate", no_argument, 0, 'C'},
|
||||||
{"print-pid", required_argument, 0, 'p'},
|
{"print-pid", required_argument, 0, 'p'},
|
||||||
|
{"log-level", required_argument, 0, 'd'},
|
||||||
{"log-colorize", optional_argument, 0, 'l'},
|
{"log-colorize", optional_argument, 0, 'l'},
|
||||||
{"log-no-syslog", no_argument, 0, 's'},
|
{"log-no-syslog", no_argument, 0, 's'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
|
@ -195,11 +197,12 @@ main(int argc, char *const *argv)
|
||||||
char *config_path = NULL;
|
char *config_path = NULL;
|
||||||
enum bar_backend backend = BAR_BACKEND_AUTO;
|
enum bar_backend backend = BAR_BACKEND_AUTO;
|
||||||
|
|
||||||
|
enum log_class log_level = LOG_CLASS_INFO;
|
||||||
enum log_colorize log_colorize = LOG_COLORIZE_AUTO;
|
enum log_colorize log_colorize = LOG_COLORIZE_AUTO;
|
||||||
bool log_syslog = true;
|
bool log_syslog = true;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int c = getopt_long(argc, argv, ":b:c:Cp:l::svh", longopts, NULL);
|
int c = getopt_long(argc, argv, ":b:c:Cp:d:l::svh", longopts, NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -238,6 +241,20 @@ main(int argc, char *const *argv)
|
||||||
pid_file = optarg;
|
pid_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'd': {
|
||||||
|
int lvl = log_level_from_string(optarg);
|
||||||
|
if (lvl < 0) {
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
"-d,--log-level: %s: argument must be one of %s\n",
|
||||||
|
optarg,
|
||||||
|
log_level_string_hint());
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
log_level = lvl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
if (optarg == NULL || strcmp(optarg, "auto") == 0)
|
if (optarg == NULL || strcmp(optarg, "auto") == 0)
|
||||||
log_colorize = LOG_COLORIZE_AUTO;
|
log_colorize = LOG_COLORIZE_AUTO;
|
||||||
|
@ -273,14 +290,14 @@ main(int argc, char *const *argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_init(log_colorize, log_syslog, LOG_FACILITY_DAEMON, LOG_CLASS_INFO);
|
log_init(log_colorize, log_syslog, LOG_FACILITY_DAEMON, log_level);
|
||||||
|
|
||||||
_Static_assert((int)LOG_CLASS_ERROR == (int)FCFT_LOG_CLASS_ERROR,
|
_Static_assert((int)LOG_CLASS_ERROR == (int)FCFT_LOG_CLASS_ERROR,
|
||||||
"fcft log level enum offset");
|
"fcft log level enum offset");
|
||||||
_Static_assert((int)LOG_COLORIZE_ALWAYS == (int)FCFT_LOG_COLORIZE_ALWAYS,
|
_Static_assert((int)LOG_COLORIZE_ALWAYS == (int)FCFT_LOG_COLORIZE_ALWAYS,
|
||||||
"fcft colorize enum mismatch");
|
"fcft colorize enum mismatch");
|
||||||
fcft_log_init(
|
fcft_log_init(
|
||||||
(enum fcft_log_colorize)log_colorize, log_syslog, FCFT_LOG_CLASS_INFO);
|
(enum fcft_log_colorize)log_colorize, log_syslog, (enum fcft_log_class)log_level);
|
||||||
|
|
||||||
const struct sigaction sa = {.sa_handler = &signal_handler};
|
const struct sigaction sa = {.sa_handler = &signal_handler};
|
||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
|
|
Loading…
Add table
Reference in a new issue