mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
Add a log_verbose logging function for debug output
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -277,11 +277,17 @@ int ratbagd_device_new(struct ratbagd_device **out,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
device->n_profiles = ratbag_device_get_num_profiles(device->lib_device);
|
||||
device->profiles = calloc(device->n_profiles, sizeof(*device->profiles));
|
||||
if (!device->profiles)
|
||||
return -ENOMEM;
|
||||
|
||||
log_verbose("%s: \"%s\", %d profiles\n",
|
||||
name,
|
||||
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);
|
||||
if (!profile)
|
||||
|
||||
@@ -34,6 +34,19 @@
|
||||
#include "ratbagd.h"
|
||||
#include "shared-macro.h"
|
||||
|
||||
static bool verbose = false;
|
||||
|
||||
void log_verbose(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
if (verbose)
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static int ratbagd_find_device(sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
@@ -449,11 +462,15 @@ int main(int argc, char *argv[])
|
||||
struct ratbagd *ctx = NULL;
|
||||
int r;
|
||||
|
||||
if (argc != 1) {
|
||||
fprintf(stderr, "%s: This program takes no arguments\n",
|
||||
program_invocation_short_name);
|
||||
r = -EINVAL;
|
||||
goto exit;
|
||||
if (argc > 1) {
|
||||
if (streq(argv[1], "--verbose")) {
|
||||
verbose = true;
|
||||
} else {
|
||||
fprintf(stderr, "Usage: %s [--verbose]\n",
|
||||
program_invocation_short_name);
|
||||
r = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
r = ratbagd_new(&ctx);
|
||||
|
||||
@@ -41,6 +41,9 @@ struct ratbagd_device;
|
||||
struct ratbagd_profile;
|
||||
struct ratbagd_resolution;
|
||||
|
||||
|
||||
void log_verbose(const char *fmt, ...) _printf_(1, 2);
|
||||
|
||||
/*
|
||||
* Profiles
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user