Skip to content

Commit

Permalink
feat(cmake): update assert message format like "Assertion failed: (fa…
Browse files Browse the repository at this point in the history
…lse), at ZLMediaKit/ext-codec/H264Rtmp.cpp#42@foobar"
  • Loading branch information
johzzy committed Nov 22, 2024
1 parent 9e319b7 commit 0ba23c9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 0ba23c9

Please sign in to comment.