diff --git a/src/shared/shell.c b/src/shared/shell.c
index 2410464..89a2e82 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
#include <stdio.h>
#include <errno.h>
+#include <syslog.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdarg.h>
#include "src/shared/util.h"
#include "src/shared/queue.h"
#include "src/shared/shell.h"
+#include "src/shared/log.h"
#define CMD_LENGTH 48
#define print_text(color, fmt, args...) \
int argc;
char **argv;
bool mode;
+ bool monitor;
int timeout;
struct io *input;
vprintf(fmt, args);
va_end(args);
+ if (data.monitor) {
+ va_start(args, fmt);
+ bt_log_vprintf(0xffff, data.name, LOG_INFO, fmt, args);
+ va_end(args);
+ }
+
if (save_input) {
if (!data.saved_prompt)
rl_restore_prompt();
if (history_search(input, -1))
add_history(input);
+ if (data.monitor)
+ bt_log_printf(0xffff, data.name, LOG_INFO, "%s", input);
+
if (wordexp(input, &w, WRDE_NOCMD))
goto done;
{ "version", no_argument, 0, 'v' },
{ "help", no_argument, 0, 'h' },
{ "timeout", required_argument, 0, 't' },
+ { "monitor", no_argument, 0, 'm' },
};
static void usage(int argc, char **argv, const struct bt_shell_opt *opt)
for (i = 0; opt && opt->options[i].name; i++)
printf("\t--%s \t%s\n", opt->options[i].name, opt->help[i]);
- printf("\t--timeout \tTimeout in seconds for non-interactive mode\n"
+ printf("\t--monitor \tEnable monitor output\n"
+ "\t--timeout \tTimeout in seconds for non-interactive mode\n"
"\t--version \tDisplay version\n"
"\t--help \t\tDisplay help\n");
}
if (opt) {
memcpy(options + offset, opt->options,
sizeof(struct option) * opt->optno);
- snprintf(optstr, sizeof(optstr), "+hvt:%s", opt->optstr);
+ snprintf(optstr, sizeof(optstr), "+mhvt:%s", opt->optstr);
} else
- snprintf(optstr, sizeof(optstr), "+hvt:");
+ snprintf(optstr, sizeof(optstr), "+mhvt:");
data.name = strrchr(argv[0], '/');
if (!data.name)
case 't':
data.timeout = atoi(optarg);
break;
+ case 'm':
+ data.monitor = true;
+ if (bt_log_open() < 0) {
+ data.monitor = false;
+ printf("Unable to open logging channel\n");
+ }
+ break;
default:
if (index < 0) {
for (index = 0; options[index].val; index++) {
data.envs = NULL;
}
+ if (data.monitor)
+ bt_log_close();
+
rl_cleanup();
data.init = false;