2 static void log_level(mrp_console_t *c, void *user_data,
12 mask = mrp_log_get_mask();
14 mask = mrp_log_parse_levels(argv[2]);
15 mrp_log_set_mask(mask);
18 printf("current logging mask: %s\n",
19 mrp_log_dump_mask(mask, buf, sizeof(buf)));
23 static void log_target(mrp_console_t *c, void *user_data,
24 int argc, char **argv)
27 const char *targets[32];
31 MRP_UNUSED(user_data);
34 target = mrp_log_get_target();
35 n = mrp_log_get_targets(targets, MRP_ARRAY_SIZE(targets));
37 printf("available log targets:\n");
38 for (i = 0; i < n; i++)
39 printf(" %s%s\n", targets[i],
40 !strcmp(targets[i], target) ? " (active)" : "");
45 if (!mrp_log_set_target(target))
46 printf("failed to change logging target to %s", target);
48 printf("changed log target to %s\n", target);
49 mrp_log_info("changed log target to %s", target);
53 printf("%s/%s invoked with wrong number of arguments\n",
61 #define LOG_GROUP_DESCRIPTION \
62 "Log commands provide means to configure the active logging settings\n" \
63 "of Murphy. Commands are provided for changing the logging level,\n" \
64 "listing log targets, and settting the active target.\n"
66 #define LEVEL_SYNTAX "[[info[,warning[,error]]]]"
67 #define LEVEL_SUMMARY "change or show the active logging level"
68 #define LEVEL_DESCRIPTION \
69 "Changes the logging level to the given one. Without arguments it\n" \
70 "prints out the current logging level.\n"
72 #define TARGET_SYNTAX "[stdout|stderr|syslog|<other targets>]"
73 #define TARGET_SUMMARY "change or show the active logging target"
74 #define TARGET_DESCRIPTION \
75 "Changes the active logging target to the given one. Without arguments\n" \
76 "it lists the available targets and the currently active one."
78 MRP_CORE_CONSOLE_GROUP(log_group, "log", LOG_GROUP_DESCRIPTION, NULL, {
79 MRP_TOKENIZED_CMD("level" , log_level , FALSE,
80 LEVEL_SYNTAX , LEVEL_SUMMARY , LEVEL_DESCRIPTION),
81 MRP_TOKENIZED_CMD("target", log_target, FALSE,
82 TARGET_SYNTAX, TARGET_SUMMARY, TARGET_DESCRIPTION)