From 9e9ad69b9592507fc5629cddc40f10fe8ce0b464 Mon Sep 17 00:00:00 2001 From: shkolnick-kun Date: Sun, 27 Oct 2019 22:15:28 +0500 Subject: [PATCH] Added command status logging Original code did not have any error code handling or logging. So I've added command execution status logging. --- src/microrl.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/microrl.c b/src/microrl.c index 5bf1962..aa79274 100644 --- a/src/microrl.c +++ b/src/microrl.c @@ -548,8 +548,27 @@ void new_line_handler(microrl_t * pThis){ pThis->print ("ERROR:too many tokens"); pThis->print (ENDL); } - if ((status > 0) && (pThis->execute != NULL)) - pThis->execute (status, tkn_arr); + if ((status > 0) && (pThis->execute != NULL)){ + status = pThis->execute(status, tkn_arr); + if (status){ + char str[16]; +#ifdef _USE_LIBC_STDIO + snprintf(str, 16, "%d", status); +#else + char *endstr = str; + if (0 > status){ + str[0] = '-'; + endstr = str + 1; + status = -status; + } + endstr = u16bit_to_str(status, endstr); + endstr[0] = 0; +#endif + pThis->print("Command exited with status:"); + pThis->print(str); + pThis->print(ENDL); + } + } print_prompt (pThis); pThis->cmdlen = 0; pThis->cursor = 0;