1、【增加】用户自定义换行符。

Signed-off-by: armink <armink.ztl@gmail.com>
pull/3/head
armink 11 years ago
parent 8c4a4b94d7
commit dda123630e

@ -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

@ -109,4 +109,4 @@ EasyLogger拥有过滤方式、输出格式、输出开关这些属性。
# 4. 许可
MIT Copyright (c) armink (armink.ztl@gmail.com)
MIT Copyright (c) armink.ztl@gmail.com

@ -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) \

@ -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 */

@ -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;
}
}

Loading…
Cancel
Save