Compare commits

...

3 Commits

Author SHA1 Message Date
Tim Newsome 6325701062 Follow OpenOCD style guide.
Change-Id: I1105c9d570890423f2712919bdaba26fdd09acab
2019-02-21 12:45:25 -08:00
Tim Newsome 7072f92513 Document log_output >stdout and >stderr.
Change-Id: I29631d9a6058fffff4d3a5b35329cc6a56ec1eea
2019-02-21 12:45:09 -08:00
Tim Newsome ae25286c87 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
2019-02-21 12:09:45 -08:00
2 changed files with 11 additions and 10 deletions

View File

@ -7702,8 +7702,9 @@ echo "Downloading kernel -- please wait"
@end deffn
@deffn Command log_output [filename]
Redirect logging to @var{filename};
the initial log output channel is stderr.
Redirect logging to @var{filename}. If @var{filename} is >stdout or >stderr,
then logging is redirected to stdout and stderr respectively.
The initial log output channel is stderr.
@end deffn
@deffn Command add_script_search_dir [directory]

View File

@ -221,12 +221,18 @@ 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 +291,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)
{