forked from drath/libratbag
ratbagd: log the device list by default
Without --verbose ratbagd just starts up with no message whatsoever. It's hard to tell if any devices are supported or if the server just hangs. Let's log the devices detected by default, at least that way we get some feedback. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
fff3589a20
commit
01c362eadc
@@ -323,10 +323,10 @@ int ratbagd_device_new(struct ratbagd_device **out,
|
||||
device->n_profiles = ratbag_device_get_num_profiles(device->lib_device);
|
||||
device->profiles = zalloc(device->n_profiles * sizeof(*device->profiles));
|
||||
|
||||
log_verbose("%s: \"%s\", %d profiles\n",
|
||||
sysname,
|
||||
ratbag_device_get_name(lib_device),
|
||||
device->n_profiles);
|
||||
log_info("%s: \"%s\", %d profiles\n",
|
||||
sysname,
|
||||
ratbag_device_get_name(lib_device),
|
||||
device->n_profiles);
|
||||
|
||||
for (i = 0; i < device->n_profiles; ++i) {
|
||||
profile = ratbag_device_get_profile(device->lib_device, i);
|
||||
|
||||
@@ -42,8 +42,12 @@
|
||||
|
||||
#include "ratbagd-test.h"
|
||||
|
||||
static bool verbose = false;
|
||||
static bool verbose_raw = false;
|
||||
enum log_level {
|
||||
LL_QUIET = 1,
|
||||
LL_INFO,
|
||||
LL_VERBOSE,
|
||||
LL_RAW,
|
||||
} log_level = LL_INFO;
|
||||
|
||||
static const char *SVG_THEMES[] = {
|
||||
"default",
|
||||
@@ -51,13 +55,23 @@ static const char *SVG_THEMES[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
void log_info(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
if (log_level >= LL_INFO)
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void log_verbose(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
if (verbose)
|
||||
if (log_level >= LL_VERBOSE)
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
@@ -376,10 +390,10 @@ static int ratbagd_new(struct ratbagd **out)
|
||||
if (!ctx->lib_ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
if (verbose_raw)
|
||||
if (log_level >= LL_RAW)
|
||||
ratbag_log_set_priority(ctx->lib_ctx,
|
||||
RATBAG_LOG_PRIORITY_RAW);
|
||||
else if (verbose)
|
||||
else if (log_level >= LL_VERBOSE)
|
||||
ratbag_log_set_priority(ctx->lib_ctx,
|
||||
RATBAG_LOG_PRIORITY_DEBUG);
|
||||
|
||||
@@ -525,12 +539,14 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if (streq(argv[1], "--verbose=raw")) {
|
||||
verbose_raw = true;
|
||||
if (streq(argv[1], "--quiet")) {
|
||||
log_level = LL_QUIET;
|
||||
} else if (streq(argv[1], "--verbose=raw")) {
|
||||
log_level = LL_RAW;
|
||||
} else if (streq(argv[1], "--verbose")) {
|
||||
verbose = true;
|
||||
log_level = LL_VERBOSE;
|
||||
} else {
|
||||
fprintf(stderr, "Usage: %s [--verbose[=raw]]\n",
|
||||
fprintf(stderr, "Usage: %s [--quiet | --verbose[=raw]]\n",
|
||||
program_invocation_short_name);
|
||||
r = -EINVAL;
|
||||
goto exit;
|
||||
|
||||
@@ -54,6 +54,7 @@ struct ratbagd_resolution;
|
||||
struct ratbagd_button;
|
||||
struct ratbagd_led;
|
||||
|
||||
void log_info(const char *fmt, ...) _printf_(1, 2);
|
||||
void log_verbose(const char *fmt, ...) _printf_(1, 2);
|
||||
void log_error(const char *fmt, ...) _printf_(1, 2);
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ def start_ratbagd(verbosity=0):
|
||||
args.append('--verbose=raw')
|
||||
elif verbosity >= 2:
|
||||
args.append('--verbose')
|
||||
elif verbosity == 0:
|
||||
args.append('--quiet')
|
||||
|
||||
ratbagd_process = subprocess.Popen(args, shell=False, stdout=sys.stdout, stderr=sys.stderr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user