kopia lustrzana https://github.com/stlink-org/stlink
logging: Don't print absolute path to source file. Fixes #548
rodzic
88c6162e45
commit
2c0ab7f0eb
|
@ -38,6 +38,11 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
|||
include(CTest)
|
||||
endif()
|
||||
|
||||
# fixup __FILE__ absolute paths in logging module
|
||||
# see: https://cmake.org/pipermail/cmake-developers/2015-January/024202.html
|
||||
string(LENGTH "${CMAKE_SOURCE_DIR}/" CMAKE_SOURCE_DIR_LENGTH)
|
||||
add_definitions(-DCMAKE_SOURCE_DIR_LENGTH=${CMAKE_SOURCE_DIR_LENGTH})
|
||||
|
||||
set(STLINK_HEADERS
|
||||
include/stlink.h
|
||||
include/stlink/usb.h
|
||||
|
|
|
@ -20,17 +20,22 @@ enum ugly_loglevel {
|
|||
int ugly_init(int maximum_threshold);
|
||||
int ugly_log(int level, const char *tag, const char *format, ...);
|
||||
|
||||
#ifndef CMAKE_SOURCE_DIR_LENGTH
|
||||
#define CMAKE_SOURCE_DIR_LENGTH 0
|
||||
#endif
|
||||
#define UGLY_LOG_FILE (__FILE__+CMAKE_SOURCE_DIR_LENGTH)
|
||||
|
||||
/** @todo we need to write this in a more generic way, for now this should compile
|
||||
on visual studio (See http://stackoverflow.com/a/8673872/1836746) */
|
||||
#define DLOG_HELPER(format, ...) ugly_log(UDEBUG, __FILE__, format, __VA_ARGS__)
|
||||
#define DLOG_HELPER(format, ...) ugly_log(UDEBUG, UGLY_LOG_FILE, format, __VA_ARGS__)
|
||||
#define DLOG(...) DLOG_HELPER(__VA_ARGS__, "")
|
||||
#define ILOG_HELPER(format, ...) ugly_log(UINFO, __FILE__, format, __VA_ARGS__)
|
||||
#define ILOG_HELPER(format, ...) ugly_log(UINFO, UGLY_LOG_FILE, format, __VA_ARGS__)
|
||||
#define ILOG(...) ILOG_HELPER(__VA_ARGS__, "")
|
||||
#define WLOG_HELPER(format, ...) ugly_log(UWARN, __FILE__, format, __VA_ARGS__)
|
||||
#define WLOG_HELPER(format, ...) ugly_log(UWARN, UGLY_LOG_FILE, format, __VA_ARGS__)
|
||||
#define WLOG(...) WLOG_HELPER(__VA_ARGS__, "")
|
||||
#define ELOG_HELPER(format, ...) ugly_log(UERROR, __FILE__, format, __VA_ARGS__)
|
||||
#define ELOG_HELPER(format, ...) ugly_log(UERROR, UGLY_LOG_FILE, format, __VA_ARGS__)
|
||||
#define ELOG(...) ELOG_HELPER(__VA_ARGS__, "")
|
||||
#define fatal_helper(format, ...) ugly_log(UFATAL, __FILE__, format, __VA_ARGS__)
|
||||
#define fatal_helper(format, ...) ugly_log(UFATAL, UGLY_LOG_FILE, format, __VA_ARGS__)
|
||||
#define fatal(...) fatal_helper(__VA_ARGS__, "")
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Ładowanie…
Reference in New Issue