From 3eef3c5ab5e4f635f2fed5fb1fd61fc7cd59cb4c Mon Sep 17 00:00:00 2001 From: armink Date: Sat, 16 May 2015 14:02:53 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91C?= =?UTF-8?q?99=E7=9A=84stdbool.h=EF=BC=8C=E4=BF=9D=E8=AF=81=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=85=A8=E9=83=A8=E9=87=87=E7=94=A8C99=E7=9A=84bool?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: armink --- demo/os/rt-thread/app/src/user_finsh_cmd.c | 4 ++-- easylogger/inc/elog.h | 14 ++++++++++---- easylogger/src/elog.c | 22 ++++++++++------------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/demo/os/rt-thread/app/src/user_finsh_cmd.c b/demo/os/rt-thread/app/src/user_finsh_cmd.c index 39ebf6b..be12965 100644 --- a/demo/os/rt-thread/app/src/user_finsh_cmd.c +++ b/demo/os/rt-thread/app/src/user_finsh_cmd.c @@ -27,9 +27,9 @@ MSH_CMD_EXPORT(get_cpuusage, Get control board cpu usage); static void elog(uint8_t argc, char **argv) { if (argc > 1) { if (!strcmp(argv[1], "on") || !strcmp(argv[1], "ON")) { - elog_set_output_enabled(TRUE); + elog_set_output_enabled(true); } else if (!strcmp(argv[1], "off") || !strcmp(argv[1], "OFF")) { - elog_set_output_enabled(FALSE); + elog_set_output_enabled(false); } else { rt_kprintf("Please input elog on or elog off.\n"); } diff --git a/easylogger/inc/elog.h b/easylogger/inc/elog.h index 9360081..0f46c77 100644 --- a/easylogger/inc/elog.h +++ b/easylogger/inc/elog.h @@ -23,7 +23,13 @@ #ifndef __ELOG_H__ #define __ELOG_H__ -#include "types.h" +#include +#include +#include + +#ifndef NULL + #define NULL 0 +#endif /* output log's level */ #define ELOG_LVL_ASSERT 0 @@ -47,7 +53,7 @@ /* output filter's keyword max length */ #define ELOG_FILTER_KW_MAX_LEN 16 /* EasyLogger software version number */ -#define ELOG_SW_VERSION "0.05.15" +#define ELOG_SW_VERSION "0.05.16" /* EasyLogger assert for developer. */ #define ELOG_ASSERT(EXPR) \ @@ -76,8 +82,8 @@ typedef enum { /* elog.c */ ElogErrCode elog_init(void); -void elog_set_output_enabled(bool_t enabled); -bool_t elog_get_output_enabled(void); +void elog_set_output_enabled(bool enabled); +bool elog_get_output_enabled(void); void elog_set_fmt(size_t set); void elog_set_filter(uint8_t level, const char *tag, const char *keyword); void elog_set_filter_lvl(uint8_t level); diff --git a/easylogger/src/elog.c b/easylogger/src/elog.c index 88c2a75..8191172 100644 --- a/easylogger/src/elog.c +++ b/easylogger/src/elog.c @@ -36,7 +36,7 @@ typedef struct { typedef struct { ElogFilter filter; size_t enabled_fmt_set; - bool_t output_enabled; + bool output_enabled; }EasyLogger, *EasyLogger_t; /* EasyLogger object */ @@ -54,7 +54,7 @@ static const char *level_output_info[] = { "D/", "V/", }; -static bool_t get_fmt_enabled(size_t set); +static bool get_fmt_enabled(size_t set); /** * EasyLogger initialize. @@ -69,7 +69,7 @@ ElogErrCode elog_init(void) { /* set level is ELOG_LVL_VERBOSE */ elog_set_filter_lvl(ELOG_LVL_VERBOSE); /* enable output */ - elog_set_output_enabled(TRUE); + elog_set_output_enabled(true); if (result == ELOG_NO_ERR) { elog_d(tag, "EasyLogger V%s is initialize success.", ELOG_SW_VERSION); @@ -84,8 +84,8 @@ ElogErrCode elog_init(void) { * * @param enabled TRUE: enable FALSE: disable */ -void elog_set_output_enabled(bool_t enabled) { - ELOG_ASSERT((enabled == FALSE) || (enabled == TRUE)); +void elog_set_output_enabled(bool enabled) { + ELOG_ASSERT((enabled == false) || (enabled == true)); elog.output_enabled = enabled; } @@ -95,7 +95,7 @@ void elog_set_output_enabled(bool_t enabled) { * * @return enable or disable */ -bool_t elog_get_output_enabled(void) { +bool elog_get_output_enabled(void) { return elog.output_enabled; } @@ -303,7 +303,7 @@ void elog_output(uint8_t level, const char *tag, const char *file, const char *f log_len += elog_strcpy(log_len, log_buf + log_len, ": "); } - /* package other log data to buffer. CRLF length is 2. '\0' must be add in the end. */ + /* package other log data to buffer. CRLF length is 2. '\0' must be added in the end by vsnprintf. */ fmt_result = vsnprintf(log_buf + log_len, ELOG_BUF_SIZE - log_len - 2 + 1, format, args); va_end(args); @@ -319,11 +319,9 @@ void elog_output(uint8_t level, const char *tag, const char *file, const char *f /* package CRLF */ if ((fmt_result > -1) && (fmt_result + log_len + 2 <= ELOG_BUF_SIZE)) { log_len += fmt_result; - /* add CRLF, cut the '\0' */ log_len += elog_strcpy(log_len, log_buf + log_len, "\r\n"); } else { - /* add CRLF */ log_buf[ELOG_BUF_SIZE - 2] = '\r'; log_buf[ELOG_BUF_SIZE - 1] = '\n'; } @@ -342,10 +340,10 @@ void elog_output(uint8_t level, const char *tag, const char *file, const char *f * * @return enable or disable */ -static bool_t get_fmt_enabled(size_t set) { +static bool get_fmt_enabled(size_t set) { if (elog.enabled_fmt_set & set) { - return TRUE; + return true; } else { - return FALSE; + return false; } }