Skip to content

Commit 4347746

Browse files
committed
[components][fal]move log redirection to privite header to avoid replace user log when incluing fal.h
1 parent 6185250 commit 4347746

File tree

6 files changed

+64
-43
lines changed

6 files changed

+64
-43
lines changed

components/fal/inc/fal_def.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,49 +25,6 @@
2525
#define FAL_DEBUG 0
2626
#endif
2727

28-
#if FAL_DEBUG
29-
#ifdef assert
30-
#undef assert
31-
#endif
32-
#define assert(EXPR) \
33-
if (!(EXPR)) \
34-
{ \
35-
FAL_PRINTF("(%s) has assert failed at %s.\n", #EXPR, __FUNCTION__); \
36-
while (1); \
37-
}
38-
39-
/* debug level log */
40-
#ifdef log_d
41-
#undef log_d
42-
#endif
43-
#define log_d(...) FAL_PRINTF("[D/FAL] (%s:%d) ", __FUNCTION__, __LINE__); FAL_PRINTF(__VA_ARGS__);FAL_PRINTF("\n")
44-
45-
#else
46-
47-
#ifdef assert
48-
#undef assert
49-
#endif
50-
#define assert(EXPR) ((void)0);
51-
52-
/* debug level log */
53-
#ifdef log_d
54-
#undef log_d
55-
#endif
56-
#define log_d(...)
57-
#endif /* FAL_DEBUG */
58-
59-
/* error level log */
60-
#ifdef log_e
61-
#undef log_e
62-
#endif
63-
#define log_e(...) FAL_PRINTF("\033[31;22m[E/FAL] (%s:%d) ", __FUNCTION__, __LINE__);FAL_PRINTF(__VA_ARGS__);FAL_PRINTF("\033[0m\n")
64-
65-
/* info level log */
66-
#ifdef log_i
67-
#undef log_i
68-
#endif
69-
#define log_i(...) FAL_PRINTF("\033[32;22m[I/FAL] "); FAL_PRINTF(__VA_ARGS__);FAL_PRINTF("\033[0m\n")
70-
7128
/* FAL flash and partition device name max length */
7229
#ifndef FAL_DEV_NAME_MAX
7330
#define FAL_DEV_NAME_MAX 24

components/fal/inc/fal_log.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2024-11-18 yekai move fal log to fal_log.h to avoid TAG conflict
9+
*/
10+
11+
#ifndef _FAL_LOG_H_
12+
#define _FAL_LOG_H_
13+
14+
#include "fal_def.h"
15+
16+
#if FAL_DEBUG
17+
#ifdef assert
18+
#undef assert
19+
#endif
20+
#define assert(EXPR) \
21+
if (!(EXPR)) \
22+
{ \
23+
FAL_PRINTF("(%s) has assert failed at %s.\n", #EXPR, __FUNCTION__); \
24+
while (1); \
25+
}
26+
27+
/* debug level log */
28+
#ifdef log_d
29+
#undef log_d
30+
#endif
31+
#define log_d(...) FAL_PRINTF("[D/FAL] (%s:%d) ", __FUNCTION__, __LINE__); FAL_PRINTF(__VA_ARGS__);FAL_PRINTF("\n")
32+
33+
#else
34+
35+
#ifdef assert
36+
#undef assert
37+
#endif
38+
#define assert(EXPR) ((void)0);
39+
40+
/* debug level log */
41+
#ifdef log_d
42+
#undef log_d
43+
#endif
44+
#define log_d(...)
45+
#endif /* FAL_DEBUG */
46+
47+
/* error level log */
48+
#ifdef log_e
49+
#undef log_e
50+
#endif
51+
#define log_e(...) FAL_PRINTF("\033[31;22m[E/FAL] (%s:%d) ", __FUNCTION__, __LINE__);FAL_PRINTF(__VA_ARGS__);FAL_PRINTF("\033[0m\n")
52+
53+
/* info level log */
54+
#ifdef log_i
55+
#undef log_i
56+
#endif
57+
#define log_i(...) FAL_PRINTF("\033[32;22m[I/FAL] "); FAL_PRINTF(__VA_ARGS__);FAL_PRINTF("\033[0m\n")
58+
59+
#endif

components/fal/src/fal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*/
1010

1111
#include <fal.h>
12+
#include "fal_def.h"
13+
#include "fal_log.h"
1214

1315
static uint8_t init_ok = 0;
1416

components/fal/src/fal_flash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <fal.h>
1212
#include <string.h>
13+
#include "fal_log.h"
1314

1415
/* flash device table, must defined by user */
1516
#if !defined(FAL_FLASH_DEV_TABLE)

components/fal/src/fal_partition.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <fal.h>
1212
#include <string.h>
1313
#include <stdlib.h>
14+
#include "fal_log.h"
1415

1516
/* partition magic word */
1617
#define FAL_PART_MAGIC_WORD 0x45503130

components/fal/src/fal_rtt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <rtdevice.h>
1717
#include <string.h>
1818
#include <stdlib.h>
19+
#include "fal_log.h"
1920

2021
/* ========================== block device ======================== */
2122
struct fal_blk_device

0 commit comments

Comments
 (0)