1、【增加】log_x 及 assert API,简化用户的书写方式;

2、【增加】按产品模块可配置日志输出优先级的功能。

Signed-off-by: armink <armink.ztl@gmail.com>
pull/3/merge
armink 9 years ago
parent 7a3d4314d1
commit abbf1e0f19

@ -25,20 +25,13 @@
* Function: non-os stm32f10x demo. * Function: non-os stm32f10x demo.
* Created on: 2015-07-31 * Created on: 2015-07-31
*/ */
#include "bsp.h"
#include <stdio.h>
#include <stdlib.h>
#include "elog.h"
#define LOG_TAG "main" #define LOG_TAG "main"
#define assert ELOG_ASSERT
#define log_a(...) elog_a(LOG_TAG, __VA_ARGS__) #include <elog.h>
#define log_e(...) elog_e(LOG_TAG, __VA_ARGS__) #include <bsp.h>
#define log_w(...) elog_w(LOG_TAG, __VA_ARGS__) #include <stdio.h>
#define log_i(...) elog_i(LOG_TAG, __VA_ARGS__) #include <stdlib.h>
#define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#define log_v(...) elog_v(LOG_TAG, __VA_ARGS__)
static void test_elog(void); static void test_elog(void);

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyLogger Library. * This file is part of the EasyLogger Library.
* *
* Copyright (c) 2015, Armink, <armink.ztl@gmail.com> * Copyright (c) 2015-2017, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -26,19 +26,12 @@
* Created on: 2015-07-30 * Created on: 2015-07-30
*/ */
#define LOG_TAG "main"
#include <elog.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "elog.h"
#define LOG_TAG "main"
#define assert ELOG_ASSERT
#define log_a(...) elog_a(LOG_TAG, __VA_ARGS__)
#define log_e(...) elog_e(LOG_TAG, __VA_ARGS__)
#define log_w(...) elog_w(LOG_TAG, __VA_ARGS__)
#define log_i(...) elog_i(LOG_TAG, __VA_ARGS__)
#define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#define log_v(...) elog_v(LOG_TAG, __VA_ARGS__)
static void test_elog(void); static void test_elog(void);

@ -1,14 +1,16 @@
#include "app_task.h" #define LOG_TAG "main"
#include <app_task.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "bsp.h" #include <bsp.h>
#include "elog_flash.h" #include <elog_flash.h>
#include "easyflash.h" #include <easyflash.h>
#include "finsh.h" #include <finsh.h>
#include "shell.h" #include <shell.h>
#include "cpuusage.h" #include <cpuusage.h>
#include "delay_conf.h" #include <delay_conf.h>
#include "utils.h" #include <utils.h>
#ifdef __CC_ARM #ifdef __CC_ARM
extern int Image$$RW_IRAM1$$ZI$$Limit; extern int Image$$RW_IRAM1$$ZI$$Limit;
@ -18,15 +20,6 @@ extern int Image$$RW_IRAM1$$ZI$$Limit;
extern int __bss_end; extern int __bss_end;
#endif #endif
#define LOG_TAG "main"
#define assert ELOG_ASSERT
#define log_a(...) elog_a(LOG_TAG, __VA_ARGS__)
#define log_e(...) elog_e(LOG_TAG, __VA_ARGS__)
#define log_w(...) elog_w(LOG_TAG, __VA_ARGS__)
#define log_i(...) elog_i(LOG_TAG, __VA_ARGS__)
#define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#define log_v(...) elog_v(LOG_TAG, __VA_ARGS__)
#define thread_sys_monitor_prio 30 #define thread_sys_monitor_prio 30
ALIGN(RT_ALIGN_SIZE) ALIGN(RT_ALIGN_SIZE)

@ -67,7 +67,7 @@ if (!(EXPR)) \
while (1); \ while (1); \
} }
/* EasyFlash software version number */ /* EasyFlash software version number */
#define EF_SW_VERSION "2.11.24" #define EF_SW_VERSION "2.12.08"
typedef struct _ef_env{ typedef struct _ef_env{
char *key; char *key;

@ -185,6 +185,15 @@ EfErrCode ef_env_set_default(void){
result = ef_save_env(); result = ef_save_env();
#ifdef EF_ENV_USING_PFS_MODE
/* reset other PFS area's data */
if (result == EF_NO_ERR) {
env_cache_changed = true;
result = ef_save_env();
}
#endif
return result; return result;
} }

@ -189,6 +189,14 @@ EfErrCode ef_env_set_default(void){
result = ef_save_env(); result = ef_save_env();
#ifdef EF_ENV_USING_PFS_MODE
/* reset other PFS area's data */
if (result == EF_NO_ERR) {
env_cache_changed = true;
result = ef_save_env();
}
#endif
return result; return result;
} }

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyLogger Library. * This file is part of the EasyLogger Library.
* *
* Copyright (c) 2015, Armink, <armink.ztl@gmail.com> * Copyright (c) 2015-2017, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -26,19 +26,12 @@
* Created on: 2015-07-30 * Created on: 2015-07-30
*/ */
#define LOG_TAG "main"
#include <elog.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h> #include <windows.h>
#include "elog.h"
#define LOG_TAG "main"
#define assert ELOG_ASSERT
#define log_a(...) elog_a(LOG_TAG, __VA_ARGS__)
#define log_e(...) elog_e(LOG_TAG, __VA_ARGS__)
#define log_w(...) elog_w(LOG_TAG, __VA_ARGS__)
#define log_i(...) elog_i(LOG_TAG, __VA_ARGS__)
#define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#define log_v(...) elog_v(LOG_TAG, __VA_ARGS__)
static void test_elog(void); static void test_elog(void);

@ -10,7 +10,7 @@
### 1.1 初始化 ### 1.1 初始化
初始化的EasyLogger的核心功能初始化后才可以使用下面的API。 初始化的 EasyLogger 的核心功能初始化后才可以使用下面的API。
``` ```
ElogErrCode elog_init(void) ElogErrCode elog_init(void)
@ -40,26 +40,32 @@ void elog_start(void)
#### 1.3.1 输出基本日志 #### 1.3.1 输出基本日志
所有级别的日志输出方法如下,每种级别都有一种简写方式,用户可以自行选择。 所有级别的日志输出方法如下,每种级别都有两种简化方式,用户可以自行选择。
```c ```c
#define elog_assert(tag, ...) #define elog_assert(tag, ...)
#define elog_a(tag, ...) //简写 #define elog_a(tag, ...) //简化方式1每次需填写 LOG_TAG
#define log_a(...) //简化方式2LOG_TAG 已经在文件顶部定义,使用前无需填写 LOG_TAG
#define elog_error(tag, ...) #define elog_error(tag, ...)
#define elog_e(tag, ...) #define elog_e(tag, ...)
#define log_a(...)
#define elog_warn(tag, ...) #define elog_warn(tag, ...)
#define elog_w(tag, ...) #define elog_w(tag, ...)
#define log_a(...)
#define elog_info(tag, ...) #define elog_info(tag, ...)
#define elog_i(tag, ...) #define elog_i(tag, ...)
#define log_a(...)
#define elog_debug(tag, ...) #define elog_debug(tag, ...)
#define elog_d(tag, ...) #define elog_d(tag, ...)
#define log_a(...)
#define elog_verbose(tag, ...) #define elog_verbose(tag, ...)
#define elog_v(tag, ...) #define elog_v(tag, ...)
#define log_a(...)
``` ```
|参数 |描述| |参数 |描述|
@ -67,43 +73,55 @@ void elog_start(void)
|tag |日志标签| |tag |日志标签|
|... |不定参格式,与`printf`入参一致,放入将要输出日志| |... |不定参格式,与`printf`入参一致,放入将要输出日志|
**建议**:对于每个文件或者每个模块,可以重新覆盖定义上述日志输出宏定义,如下所示。这样的优点就是降低代码书写量,统一日志书写格式,代码可以做到尽可能少的依赖某个日志库,同时部分复用代码无需修改日志输出方法,可直接拷贝至其他模块或者其他项目,提高软件的可重用性 **技巧一** :对于每个源代码文件,可以在引用 `elog.h` 上方,根据模块的不同功能,定义不同的日志标签,如下所示,这样既可直接使用 `log_x` 这类无需输入标签的简化方式 API
```c ```c
//WiFi协议处理(/wifi/proto.c) //WiFi 协议处理(位于 /wifi/proto.c 源代码文件)
#define LOG_TAG "wifi.proto" #define LOG_TAG "wifi.proto"
#define log_e(...) elog_e(LOG_TAG, __VA_ARGS__)
#define log_w(...) elog_w(LOG_TAG, __VA_ARGS__)
#define log_i(...) elog_i(LOG_TAG, __VA_ARGS__)
#if WIFI_DEBUG
#define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#else
#define log_d(...)
#endif
//WiFi数据打包处理(/wifi/package.c) #include <elog.h>
log_e("我是 wifi.proto 日志");
```
```C
//WiFi 数据打包处理(位于 /wifi/package.c 源代码文件)
#define LOG_TAG "wifi.package" #define LOG_TAG "wifi.package"
#if WIFI_DEBUG #include <elog.h>
#define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#else log_w("我是 wifi.package 日志");
#define log_d(...) ```
#endif
//CAN命令解析(/can/disp.c) ```C
//CAN 命令解析(位于 /can/disp.c 源代码文件)
#define LOG_TAG "can.disp" #define LOG_TAG "can.disp"
#define log_e(...) elog_e(LOG_TAG, __VA_ARGS__)
#if CAN_DEBUG #include <elog.h>
#define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#else log_w("我是 can.disp 日志");
#define log_d(...) ```
#endif
**技巧二** :为了实现按照模块、子模块作用域来限制日志输出级别的功能,可以按照下面的方式,在模块的头文件中定义以下宏定义:
```C
/**
* Log default configuration for EasyLogger.
* NOTE: Must defined before including the <elog.h>
*/
#if !defined(LOG_TAG)
#define LOG_TAG "xx"
#endif
#undef LOG_LVL
#if defined(XX_LOG_LVL)
#define LOG_LVL XX_LOG_LVL
#endif
``` ```
#### 1.3.2 输出RAW格式日志 XX 是模块名称的缩写,该段内容务必定义在 `elog.h` 之前,否则失效;这样做的 **好处** 是,如果模块内的源文件没有定义 TAG ,则会自动引用该段内容中的定义的 TAG 。同时可以在 头文件中可以配置 `XX_LOG_LVL` ,这样只会输出比这个优先级高或相等级别的日志。当然 XX_LOG_LVL 这个宏也可以不定义,此时会输出全部级别的日志,定义为 ASSERT 级别,就只剩断言信息了。
此时我们就能够实现 **源文件->子模块->模块->EasyLogger全局** 对于其中任何环节的日志配置及控制。调试时想要查看其中任何环节的日志,或者调整其中的某个环节日志级别,都会非常轻松,极大的提高了调试的灵活性及效率。
#### 1.3.2 输出 RAW 格式日志
``` ```
void elog_raw(const char *format, ...) void elog_raw(const char *format, ...)
@ -121,6 +139,7 @@ EasyLogger自带的断言可以直接用户软件在断言表达式不成
``` ```
#define ELOG_ASSERT(EXPR) #define ELOG_ASSERT(EXPR)
#define assert(EXPR) //简化形式
``` ```
|参数 |描述| |参数 |描述|
@ -173,13 +192,15 @@ void elog_output_lock_enabled(bool enabled)
```c ```c
/* EasyLogger断言钩子方法 */ /* EasyLogger断言钩子方法 */
static void elog_user_assert_hook(const char* ex, const char* func, size_t line) { static void elog_user_assert_hook(const char* ex, const char* func, size_t line) {
/* 失能异步输出方式(异步输出模块自带方法) */
elog_async_enabled(false);
/* 失能日志输出锁 */ /* 失能日志输出锁 */
elog_output_lock_enabled(false); elog_output_lock_enabled(false);
/* 失能EasyLogger的Flash插件自带同步锁Flash插件自带方法 */ /* 失能 EasyLogger Flash 插件自带同步锁Flash 插件自带方法) */
elog_flash_lock_enabled(false); elog_flash_lock_enabled(false);
/* 输出断言信息 */ /* 输出断言信息 */
elog_a("elog", "(%s) has assert failed at %s:%ld.\n", ex, func, line); elog_a("elog", "(%s) has assert failed at %s:%ld.\n", ex, func, line);
/* 将缓冲区中所有日志保存至FlashFlash插件自带方法 */ /* 将缓冲区中所有日志保存至 Flash Flash 插件自带方法) */
elog_flash_flush(); elog_flash_flush();
while(1); while(1);
} }
@ -363,7 +384,7 @@ size_t elog_async_get_log(char *log, size_t size)
#### 1.9.3 在异步输出模式下获取行日志(以换行符结尾) #### 1.9.3 在异步输出模式下获取行日志(以换行符结尾)
异步模式下获取行日志与 1.9.2 中的直接获取日志功能类似,只不过这里所获取到的日志内容,必须为 **行日志** (以换行符结尾)格式,为后续的日志按行分析功能提供便利。如果设定日志长度小于日志缓冲区中已存在日志长度,将只会返回日志缓冲区中行日志的长度。如果缓冲区中不存在行日志,将不能保证返回的日志格式是行日志。 异步模式下获取行日志与 1.9.2 中的直接获取日志功能类似,只不过这里所获取到的日志内容,必须为 **行日志** (以换行符结尾)格式,为后续的日志按行分析功能提供便利。如果设定日志长度小于日志缓冲区中已存在日志长度,将只会返回日志缓冲区中行日志的长度。如果缓冲区中不存在行日志,将不能保证返回的日志格式是行日志。
```C ```C
size_t elog_async_get_line_log(char *log, size_t size) size_t elog_async_get_line_log(char *log, size_t size)

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyLogger Library. * This file is part of the EasyLogger Library.
* *
* Copyright (c) 2015, Armink, <armink.ztl@gmail.com> * Copyright (c) 2015-2017, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -50,24 +50,75 @@ extern "C" {
#define ELOG_LVL_TOTAL_NUM 6 #define ELOG_LVL_TOTAL_NUM 6
/* EasyLogger software version number */ /* EasyLogger software version number */
#define ELOG_SW_VERSION "1.12.19" #define ELOG_SW_VERSION "2.0.0"
/* EasyLogger assert for developer. */ /* EasyLogger assert for developer. */
#ifdef ELOG_ASSERT_ENABLE #ifdef ELOG_ASSERT_ENABLE
#define ELOG_ASSERT(EXPR) \ #define ELOG_ASSERT(EXPR) \
if (!(EXPR)) \ if (!(EXPR)) \
{ \ { \
if (elog_assert_hook == NULL) { \ if (elog_assert_hook == NULL) { \
elog_a("elog", "(%s) has assert failed at %s:%ld.", #EXPR, __FUNCTION__, __LINE__); \ elog_a("elog", "(%s) has assert failed at %s:%ld.", #EXPR, __FUNCTION__, __LINE__); \
while (1); \ while (1); \
} else { \ } else { \
elog_assert_hook(#EXPR, __FUNCTION__, __LINE__); \ elog_assert_hook(#EXPR, __FUNCTION__, __LINE__); \
} \ } \
} }
#else #else
#define ELOG_ASSERT(EXPR) ((void)0); #define ELOG_ASSERT(EXPR) ((void)0);
#endif #endif
#ifndef ELOG_OUTPUT_ENABLE
#define elog_a(tag, ...)
#define elog_e(tag, ...)
#define elog_w(tag, ...)
#define elog_i(tag, ...)
#define elog_d(tag, ...)
#define elog_v(tag, ...)
#else /* ELOG_OUTPUT_ENABLE */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_ASSERT
#define elog_assert(tag, ...) \
elog_output(ELOG_LVL_ASSERT, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_assert(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_ASSERT */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_ERROR
#define elog_error(tag, ...) \
elog_output(ELOG_LVL_ERROR, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_error(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_ERROR */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_WARN
#define elog_warn(tag, ...) \
elog_output(ELOG_LVL_WARN, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_warn(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_WARN */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_INFO
#define elog_info(tag, ...) \
elog_output(ELOG_LVL_INFO, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_info(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_INFO */
#if ELOG_OUTPUT_LVL >= ELOG_LVL_DEBUG
#define elog_debug(tag, ...) \
elog_output(ELOG_LVL_DEBUG, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_debug(tag, ...)
#endif /* ELOG_OUTPUT_LVL >= ELOG_LVL_DEBUG */
#if ELOG_OUTPUT_LVL == ELOG_LVL_VERBOSE
#define elog_verbose(tag, ...) \
elog_output(ELOG_LVL_VERBOSE, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else
#define elog_verbose(tag, ...)
#endif /* ELOG_OUTPUT_LVL == ELOG_LVL_VERBOSE */
#endif /* ELOG_OUTPUT_ENABLE */
/* all formats index */ /* all formats index */
typedef enum { typedef enum {
ELOG_FMT_LVL = 1 << 0, /**< level */ ELOG_FMT_LVL = 1 << 0, /**< level */
@ -132,67 +183,58 @@ void elog_assert_set_hook(void (*hook)(const char* expr, const char* func, size_
int8_t elog_find_lvl(const char *log); int8_t elog_find_lvl(const char *log);
const char *elog_find_tag(const char *log, uint8_t lvl, size_t *tag_len); const char *elog_find_tag(const char *log, uint8_t lvl, size_t *tag_len);
#ifndef ELOG_OUTPUT_ENABLE #define elog_a(tag, ...) elog_assert(tag, __VA_ARGS__)
#define elog_e(tag, ...) elog_error(tag, __VA_ARGS__)
#define elog_a(tag, ...) #define elog_w(tag, ...) elog_warn(tag, __VA_ARGS__)
#define elog_e(tag, ...) #define elog_i(tag, ...) elog_info(tag, __VA_ARGS__)
#define elog_w(tag, ...) #define elog_d(tag, ...) elog_debug(tag, __VA_ARGS__)
#define elog_i(tag, ...) #define elog_v(tag, ...) elog_verbose(tag, __VA_ARGS__)
#define elog_d(tag, ...)
#define elog_v(tag, ...)
#else /* ELOG_OUTPUT_ENABLE */ /**
* log API short definition
#if ELOG_OUTPUT_LVL >= ELOG_LVL_ASSERT * NOTE: The `LOG_TAG` and `LOG_LVL` must defined before including the <elog.h> when you want to use log_x API.
#define elog_assert(tag, ...) \ */
elog_output(ELOG_LVL_ASSERT, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) #if !defined(LOG_TAG)
#define LOG_TAG "NO_TAG"
#endif
#if !defined(LOG_LVL)
#define LOG_LVL ELOG_LVL_VERBOSE
#endif
#if LOG_LVL >= ELOG_LVL_ASSERT
#define log_a(...) elog_a(LOG_TAG, __VA_ARGS__)
#else #else
#define elog_assert(tag, ...) #define log_a(...) ((void)0);
#endif #endif
#if LOG_LVL >= ELOG_LVL_ERROR
#if ELOG_OUTPUT_LVL >= ELOG_LVL_ERROR #define log_e(...) elog_e(LOG_TAG, __VA_ARGS__)
#define elog_error(tag, ...) \
elog_output(ELOG_LVL_ERROR, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else #else
#define elog_error(tag, ...) #define log_e(...) ((void)0);
#endif #endif
#if LOG_LVL >= ELOG_LVL_WARN
#if ELOG_OUTPUT_LVL >= ELOG_LVL_WARN #define log_w(...) elog_w(LOG_TAG, __VA_ARGS__)
#define elog_warn(tag, ...) \
elog_output(ELOG_LVL_WARN, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else #else
#define elog_warn(tag, ...) #define log_w(...) ((void)0);
#endif #endif
#if LOG_LVL >= ELOG_LVL_INFO
#if ELOG_OUTPUT_LVL >= ELOG_LVL_INFO #define log_i(...) elog_i(LOG_TAG, __VA_ARGS__)
#define elog_info(tag, ...) \
elog_output(ELOG_LVL_INFO, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else #else
#define elog_info(tag, ...) #define log_i(...) ((void)0);
#endif #endif
#if LOG_LVL >= ELOG_LVL_DEBUG
#if ELOG_OUTPUT_LVL >= ELOG_LVL_DEBUG #define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#define elog_debug(tag, ...) \
elog_output(ELOG_LVL_DEBUG, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else #else
#define elog_debug(tag, ...) #define log_d(...) ((void)0);
#endif #endif
#if LOG_LVL >= ELOG_LVL_VERBOSE
#if ELOG_OUTPUT_LVL == ELOG_LVL_VERBOSE #define log_v(...) elog_v(LOG_TAG, __VA_ARGS__)
#define elog_verbose(tag, ...) \
elog_output(ELOG_LVL_VERBOSE, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
#else #else
#define elog_verbose(tag, ...) #define log_v(...) ((void)0);
#endif #endif
#endif /* ELOG_OUTPUT_ENABLE */ /* assert API short definition */
#if !defined(assert)
#define elog_a(tag, ...) elog_assert(tag, __VA_ARGS__) #define assert ELOG_ASSERT
#define elog_e(tag, ...) elog_error(tag, __VA_ARGS__) #endif
#define elog_w(tag, ...) elog_warn(tag, __VA_ARGS__)
#define elog_i(tag, ...) elog_info(tag, __VA_ARGS__)
#define elog_d(tag, ...) elog_debug(tag, __VA_ARGS__)
#define elog_v(tag, ...) elog_verbose(tag, __VA_ARGS__)
/* elog_buf.c */ /* elog_buf.c */
void elog_buf_enabled(bool enabled); void elog_buf_enabled(bool enabled);

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyLogger Library. * This file is part of the EasyLogger Library.
* *
* Copyright (c) 2015, Armink, <armink.ztl@gmail.com> * Copyright (c) 2015-2017, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -26,19 +26,14 @@
* Created on: 2015-06-05 * Created on: 2015-06-05
*/ */
#define LOG_TAG "elog.flash"
#include "elog_flash.h" #include "elog_flash.h"
#include <easyflash.h> #include <easyflash.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define log_a(...) elog_a("elog.flash", __VA_ARGS__)
#define log_e(...) elog_e("elog.flash", __VA_ARGS__)
#define log_w(...) elog_w("elog.flash", __VA_ARGS__)
#define log_i(...) elog_i("elog.flash", __VA_ARGS__)
#define log_d(...) elog_d("elog.flash", __VA_ARGS__)
#define log_v(...) elog_v("elog.flash", __VA_ARGS__)
#ifdef ELOG_FLASH_USING_BUF_MODE #ifdef ELOG_FLASH_USING_BUF_MODE
/* flash log buffer */ /* flash log buffer */
static char log_buf[ELOG_FLASH_BUF_SIZE] = { 0 }; static char log_buf[ELOG_FLASH_BUF_SIZE] = { 0 };

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyLogger Library. * This file is part of the EasyLogger Library.
* *
* Copyright (c) 2015, Armink, <armink.ztl@gmail.com> * Copyright (c) 2015-2017, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -41,7 +41,7 @@ extern "C" {
#endif #endif
/* EasyLogger flash log plugin's software version number */ /* EasyLogger flash log plugin's software version number */
#define ELOG_FLASH_SW_VERSION "1.12.19" #define ELOG_FLASH_SW_VERSION "V2.0.0"
/* elog_flash.c */ /* elog_flash.c */
ElogErrCode elog_flash_init(void); ElogErrCode elog_flash_init(void);

@ -26,6 +26,8 @@
* Created on: 2015-04-28 * Created on: 2015-04-28
*/ */
#define LOG_TAG "elog"
#include <elog.h> #include <elog.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
@ -60,50 +62,50 @@
* CSI(Control Sequence Introducer/Initiator) sign * CSI(Control Sequence Introducer/Initiator) sign
* more information on https://en.wikipedia.org/wiki/ANSI_escape_code * more information on https://en.wikipedia.org/wiki/ANSI_escape_code
*/ */
#define CSI_START "\033[" #define CSI_START "\033["
#define CSI_END "\033[0m" #define CSI_END "\033[0m"
/* output log front color */ /* output log front color */
#define F_BLACK "30;" #define F_BLACK "30;"
#define F_RED "31;" #define F_RED "31;"
#define F_GREEN "32;" #define F_GREEN "32;"
#define F_YELLOW "33;" #define F_YELLOW "33;"
#define F_BLUE "34;" #define F_BLUE "34;"
#define F_MAGENTA "35;" #define F_MAGENTA "35;"
#define F_CYAN "36;" #define F_CYAN "36;"
#define F_WHITE "37;" #define F_WHITE "37;"
/* output log background color */ /* output log background color */
#define B_NULL #define B_NULL
#define B_BLACK "40;" #define B_BLACK "40;"
#define B_RED "41;" #define B_RED "41;"
#define B_GREEN "42;" #define B_GREEN "42;"
#define B_YELLOW "43;" #define B_YELLOW "43;"
#define B_BLUE "44;" #define B_BLUE "44;"
#define B_MAGENTA "45;" #define B_MAGENTA "45;"
#define B_CYAN "46;" #define B_CYAN "46;"
#define B_WHITE "47;" #define B_WHITE "47;"
/* output log fonts style */ /* output log fonts style */
#define S_BOLD "1m" #define S_BOLD "1m"
#define S_UNDERLINE "4m" #define S_UNDERLINE "4m"
#define S_BLINK "5m" #define S_BLINK "5m"
#define S_NORMAL "22m" #define S_NORMAL "22m"
/* output log default color definition: [front color] + [background color] + [show style] */ /* output log default color definition: [front color] + [background color] + [show style] */
#ifndef ELOG_COLOR_ASSERT #ifndef ELOG_COLOR_ASSERT
#define ELOG_COLOR_ASSERT (F_MAGENTA B_NULL S_NORMAL) #define ELOG_COLOR_ASSERT (F_MAGENTA B_NULL S_NORMAL)
#endif #endif
#ifndef ELOG_COLOR_ERROR #ifndef ELOG_COLOR_ERROR
#define ELOG_COLOR_ERROR (F_RED B_NULL S_NORMAL) #define ELOG_COLOR_ERROR (F_RED B_NULL S_NORMAL)
#endif #endif
#ifndef ELOG_COLOR_WARN #ifndef ELOG_COLOR_WARN
#define ELOG_COLOR_WARN (F_YELLOW B_NULL S_NORMAL) #define ELOG_COLOR_WARN (F_YELLOW B_NULL S_NORMAL)
#endif #endif
#ifndef ELOG_COLOR_INFO #ifndef ELOG_COLOR_INFO
#define ELOG_COLOR_INFO (F_CYAN B_NULL S_NORMAL) #define ELOG_COLOR_INFO (F_CYAN B_NULL S_NORMAL)
#endif #endif
#ifndef ELOG_COLOR_DEBUG #ifndef ELOG_COLOR_DEBUG
#define ELOG_COLOR_DEBUG (F_GREEN B_NULL S_NORMAL) #define ELOG_COLOR_DEBUG (F_GREEN B_NULL S_NORMAL)
#endif #endif
#ifndef ELOG_COLOR_VERBOSE #ifndef ELOG_COLOR_VERBOSE
#define ELOG_COLOR_VERBOSE (F_BLUE B_NULL S_NORMAL) #define ELOG_COLOR_VERBOSE (F_BLUE B_NULL S_NORMAL)
#endif #endif
#endif /* ELOG_COLOR_ENABLE */ #endif /* ELOG_COLOR_ENABLE */
@ -111,8 +113,6 @@
static EasyLogger elog; static EasyLogger elog;
/* every line log's buffer */ /* every line log's buffer */
static char log_buf[ELOG_LINE_BUF_SIZE] = { 0 }; static char log_buf[ELOG_LINE_BUF_SIZE] = { 0 };
/* log tag */
static const char *log_tag = "elog";
/* level output info */ /* level output info */
static const char *level_output_info[] = { static const char *level_output_info[] = {
[ELOG_LVL_ASSERT] = "A/", [ELOG_LVL_ASSERT] = "A/",
@ -199,8 +199,7 @@ void elog_start(void) {
#endif #endif
/* show version */ /* show version */
elog_i(log_tag, "EasyLogger V%s is initialize success.", ELOG_SW_VERSION); log_i("EasyLogger V%s is initialize success.", ELOG_SW_VERSION);
elog_i(log_tag, "You can get the latest version on https://github.com/armink/EasyLogger .");
} }
/** /**

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyLogger Library. * This file is part of the EasyLogger Library.
* *
* Copyright (c) 2015, Armink, <armink.ztl@gmail.com> * Copyright (c) 2015-2017, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -29,19 +29,6 @@
#include <elog.h> #include <elog.h>
#include <string.h> #include <string.h>
#define LOG_TAG "elog.utils"
#define assert ELOG_ASSERT
#define log_e(...) elog_e(LOG_TAG, __VA_ARGS__)
#define log_w(...) elog_w(LOG_TAG, __VA_ARGS__)
#ifdef ELOG_DEBUG
#define log_d(...) elog_d(LOG_TAG, __VA_ARGS__)
#define log_v(...) elog_v(LOG_TAG, __VA_ARGS__)
#else
#define log_d(...)
#define log_v(...)
#endif
/** /**
* another copy string function * another copy string function
* *

Loading…
Cancel
Save