mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
72 lines
2.3 KiB
C
72 lines
2.3 KiB
C
|
|
/*
|
|
* sfe_debug.h
|
|
* SFE debug macros.
|
|
*
|
|
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
* copyright notice and this permission notice appear in all copies.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
/*
|
|
* The following are debug macros used throughout the SFE.
|
|
*
|
|
* The DEBUG_LEVEL enables the followings based on its value,
|
|
* when dynamic debug option is disabled.
|
|
*
|
|
* 0 = OFF
|
|
* 1 = ASSERTS / ERRORS
|
|
* 2 = 1 + WARN
|
|
* 3 = 2 + INFO
|
|
* 4 = 3 + TRACE
|
|
*/
|
|
#define DEBUG_LEVEL 2
|
|
|
|
#if (DEBUG_LEVEL < 1)
|
|
#define DEBUG_ASSERT(s, ...)
|
|
#define DEBUG_ERROR(s, ...)
|
|
#else
|
|
#define DEBUG_ASSERT(c, s, ...) if (!(c)) { pr_emerg("ASSERT: %s:%d:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__); BUG(); }
|
|
#define DEBUG_ERROR(s, ...) pr_err("%s:%d:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
|
#endif
|
|
|
|
#if defined(CONFIG_DYNAMIC_DEBUG)
|
|
/*
|
|
* Compile messages for dynamic enable/disable
|
|
*/
|
|
#define DEBUG_WARN(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
|
#define DEBUG_INFO(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
|
#define DEBUG_TRACE(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
|
#else
|
|
|
|
/*
|
|
* Statically compile messages at different levels
|
|
*/
|
|
#if (DEBUG_LEVEL < 2)
|
|
#define DEBUG_WARN(s, ...)
|
|
#else
|
|
#define DEBUG_WARN(s, ...) pr_warn("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
|
#endif
|
|
|
|
#if (DEBUG_LEVEL < 3)
|
|
#define DEBUG_INFO(s, ...)
|
|
#else
|
|
#define DEBUG_INFO(s, ...) pr_notice("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
|
#endif
|
|
|
|
#if (DEBUG_LEVEL < 4)
|
|
#define DEBUG_TRACE(s, ...)
|
|
#else
|
|
#define DEBUG_TRACE(s, ...) pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
|
#endif
|
|
#endif
|