WXK
2024-12-16 9201a33e45484b3247271759c91c158063baccac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/************************************************************************
 * @file     pan_sys_log.h
 * @version  V1.00
 * $Revision: 0 $
 * $Date: 2023/11/08 $
 * @brief    Header file for the Panchip Series system logging functionality.
 *
 * @note     This library provides functions and definitions for system
 *           logging and debugging features specific to the Panchip Series
 *           microcontroller family.
 * Copyright (C) 2023 Panchip Technology Corp. All rights reserved.
 *****************************************************************************/
 
#ifndef __PAN_SYS_LOG_H__
#define __PAN_SYS_LOG_H__
 
#include <stdio.h>
#include <stdint.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
#define DBG_ON     0
#define INFO_ON    1
#define WARN_ON    1
#define ERR_ON     1
#define TEST_ON    1
#define ASSERT_ON  1
 
#define SYS_ABORT()    do { } while (1) //sys_abort()
 
#define LOG(flags, ...)    \
    do {                                \
        if (flags)                      \
            printf(__VA_ARGS__);    \
    } while (0)
 
#define SYS_DBG(fmt, ...)   LOG(DBG_ON, "[SYS DBG] %s:%s():%d, "   fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define SYS_INFO(fmt, ...)  LOG(INFO_ON, "[SYS INFO] %s:%s():%d, " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define SYS_WARN(fmt, ...)  LOG(WARN_ON, "[SYS WARN] %s:%s():%d, " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define SYS_TEST(...)  LOG(TEST_ON, __VA_ARGS__)
 
#define SYS_ERR(fmt, ...)                               \
    do {                                                    \
        LOG(ERR_ON, "[SYS ERR] %s:%s():%d, "fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);   \
        if (ERR_ON)                                                         \
            SYS_ABORT();                                                        \
    } while (0)
 
    
#ifdef ASSERT_ON
#define SYS_ASSERT(expr)    ((expr) ? (void)0u : SYS_AssertError((uint8_t*)__FILE__, __LINE__))
extern void SYS_AssertError(uint8_t* file, uint32_t line);
#else
#define SYS_ASSERT(expr)    ((void)0u)
#endif
 
#ifdef __cplusplus
}
#endif
 
#endif /* __PAN_SYS_LOG_H__ */