diff --git a/LICENSE b/LICENSE index c2ca4de..8d9bc06 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 armink (armink.ztl@gmail.com) +Copyright (c) 2015 Armink (armink.ztl@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index 6412e5c..209f006 100644 --- a/README.md +++ b/README.md @@ -109,4 +109,4 @@ EasyLogger拥有过滤方式、输出格式、输出开关这些属性。 # 4. 许可 -MIT Copyright (c) armink (armink.ztl@gmail.com) +MIT Copyright (c) armink.ztl@gmail.com diff --git a/easylogger/inc/elog.h b/easylogger/inc/elog.h index 59121ec..27b48af 100644 --- a/easylogger/inc/elog.h +++ b/easylogger/inc/elog.h @@ -58,8 +58,10 @@ extern "C" { #define ELOG_FILTER_TAG_MAX_LEN 16 /* output filter's keyword max length */ #define ELOG_FILTER_KW_MAX_LEN 16 +/* output newline sign */ +#define ELOG_NEWLINE_SIGN "\r\n" /* EasyLogger software version number */ -#define ELOG_SW_VERSION "0.06.09" +#define ELOG_SW_VERSION "0.06.23" /* EasyLogger assert for developer. */ #define ELOG_ASSERT(EXPR) \ diff --git a/easylogger/src/elog.c b/easylogger/src/elog.c index 7432241..bfae4a5 100644 --- a/easylogger/src/elog.c +++ b/easylogger/src/elog.c @@ -200,7 +200,7 @@ void elog_raw(const char *format, ...) { */ void elog_output(uint8_t level, const char *tag, const char *file, const char *func, const long line, const char *format, ...) { - size_t tag_len = strlen(tag), log_len = 0; + size_t tag_len = strlen(tag), log_len = 0, newline_len = strlen(ELOG_NEWLINE_SIGN); char line_num[ELOG_LINE_NUM_MAX_LEN + 1] = { 0 }; char tag_sapce[ELOG_FILTER_TAG_MAX_LEN / 2 + 1] = { 0 }; va_list args; @@ -298,8 +298,8 @@ 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 added in the end by vsnprintf. */ - fmt_result = vsnprintf(log_buf + log_len, ELOG_BUF_SIZE - log_len - 2 + 1, format, args); + /* package other log data to buffer. '\0' must be added in the end by vsnprintf. */ + fmt_result = vsnprintf(log_buf + log_len, ELOG_BUF_SIZE - log_len - newline_len + 1, format, args); va_end(args); @@ -312,13 +312,13 @@ 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)) { + if ((fmt_result > -1) && (fmt_result + log_len + newline_len <= ELOG_BUF_SIZE)) { log_len += fmt_result; - log_len += elog_strcpy(log_len, log_buf + log_len, "\r\n"); + log_len += elog_strcpy(log_len, log_buf + log_len, ELOG_NEWLINE_SIGN); } else { - log_buf[ELOG_BUF_SIZE - 2] = '\r'; - log_buf[ELOG_BUF_SIZE - 1] = '\n'; + /* copy newline sign */ + strcpy(log_buf - newline_len, ELOG_NEWLINE_SIGN); } /* output log */ diff --git a/easylogger/src/elog_flash.c b/easylogger/src/elog_flash.c index 819b41d..070eecc 100644 --- a/easylogger/src/elog_flash.c +++ b/easylogger/src/elog_flash.c @@ -112,8 +112,8 @@ void elog_flash_outout(size_t index, size_t size) { log_total_size - index - read_size + read_overage_size); elog_flash_port_output((const char*) buf + read_overage_size, log_total_size - index - read_size); - //TODO CRLF Ҫͳһͷļ궨 - elog_flash_port_output("\r\n", 2); + /* output newline sign */ + elog_flash_port_output(ELOG_NEWLINE_SIGN, strlen(ELOG_NEWLINE_SIGN)); break; } }