From 0ba23c90624ca3822f1d37be397ca9953b0535e5 Mon Sep 17 00:00:00 2001 From: Johnny Date: Fri, 22 Nov 2024 15:44:44 +0800 Subject: [PATCH] feat(cmake): update assert message format like "Assertion failed: (false), at ZLMediaKit/ext-codec/H264Rtmp.cpp#42@foobar" --- src/Util/util.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Util/util.cpp b/src/Util/util.cpp index 1da99cc3..e21d1aa1 100644 --- a/src/Util/util.cpp +++ b/src/Util/util.cpp @@ -669,7 +669,14 @@ void Assert_Throw(int failed, const char *exp, const char *func, const char *fil if(str && *str){ printer << ", " << str; } - printer << "), function " << func << ", file " << file << ", line " << line << "."; +#if defined(ZLMediaKit_PARENT_DIR_LENGTH) && defined(ZLMediaKit_PARENT_DIR) + // Assertion failed: (false), at ZLMediaKit/ext-codec/H264Rtmp.cpp#42@foobar + int offset = strncmp(file, ZLMediaKit_PARENT_DIR, ZLMediaKit_PARENT_DIR_LENGTH) == 0 ? ZLMediaKit_PARENT_DIR_LENGTH + 1: 0; + printer << "), at " << (file+ offset) << "#" << line << "@" << func; +#else + printer << "), at " << file << "#" << line << "@" << func; +#endif + throw toolkit::AssertFailedException(printer); } }