diff options
author | Tim Newsome <tim@sifive.com> | 2019-02-21 12:09:45 -0800 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2019-02-21 12:09:45 -0800 |
commit | ae25286c87856df679c2d8565e1d0f0ea9a18d5f (patch) | |
tree | f70740b9a4340da6aadd2b8a319dbdc67f11d606 | |
parent | 8dd5d2a71064e8cab577b6681d08314e919af753 (diff) | |
download | riscv-openocd-ae25286c87856df679c2d8565e1d0f0ea9a18d5f.zip riscv-openocd-ae25286c87856df679c2d8565e1d0f0ea9a18d5f.tar.gz riscv-openocd-ae25286c87856df679c2d8565e1d0f0ea9a18d5f.tar.bz2 |
Add >stdout and >stderr to log_output command.
This allows people to send log output to stdout and stderr in addition
to a file.
Change-Id: I4b3f575b416c425b1e61b39e422262bf68f41091
-rw-r--r-- | src/helper/log.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/helper/log.c b/src/helper/log.c index f980774..e51943d 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -221,12 +221,19 @@ COMMAND_HANDLER(handle_debug_level_command) COMMAND_HANDLER(handle_log_output_command) { if (CMD_ARGC == 1) { - FILE *file = fopen(CMD_ARGV[0], "w"); + FILE *file = NULL; + if (!strcmp(CMD_ARGV[0], ">stdout")) { + file = stdout; + } else if (!strcmp(CMD_ARGV[0], ">stderr")) { + file = stderr; + } else { + file = fopen(CMD_ARGV[0], "w"); + } if (file == NULL) { LOG_ERROR("failed to open output log '%s'", CMD_ARGV[0]); return ERROR_FAIL; } - if (log_output != stderr && log_output != NULL) { + if (log_output != stdout && log_output != stderr && log_output != NULL) { /* Close previous log file, if it was open and wasn't stderr. */ fclose(log_output); } @@ -285,12 +292,6 @@ void log_init(void) start = last_time = timeval_ms(); } -int set_log_output(struct command_context *cmd_ctx, FILE *output) -{ - log_output = output; - return ERROR_OK; -} - /* add/remove log callback handler */ int log_add_callback(log_callback_fn fn, void *priv) { |