added feature to make asserts log to a file instead of breaking the process

This commit is contained in:
Arvid Norberg 2010-05-16 05:26:43 +00:00
parent e07bad0686
commit 6bb24bea80
3 changed files with 13 additions and 3 deletions

View File

@ -1,3 +1,5 @@
* added feature to make asserts log to a file instead of breaking the process
(production asserts)
* optimized disk I/O cache clearing * optimized disk I/O cache clearing
* added feature to ask a torrent if it needs to save its resume data or not * added feature to ask a torrent if it needs to save its resume data or not
* added setting to ignore file modification time when loading resume files * added setting to ignore file modification time when loading resume files

View File

@ -34,17 +34,21 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#if !defined TORRENT_DEBUG || TORRENT_NO_ASSERTS #if (!defined TORRENT_DEBUG && !TORRENT_PRODUCTION_ASSERTS) || TORRENT_NO_ASSERTS
#define TORRENT_ASSERT(a) do {} while(false) #define TORRENT_ASSERT(a) do {} while(false)
#else #else
#if TORRENT_PRODUCTION_ASSERTS
extern char const* libtorrent_assert_log;
#endif
#include <string> #include <string>
#ifdef __GNUC__ #ifdef __GNUC__
std::string demangle(char const* name); std::string demangle(char const* name);
#endif #endif
#if (defined __linux__ || defined __MACH__) && defined __GNUC__ && defined TORRENT_DEBUG #if (defined __linux__ || defined __MACH__) && defined __GNUC__
TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, char const* function); TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, char const* function);
#define TORRENT_ASSERT(x) do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__); } while (false) #define TORRENT_ASSERT(x) do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__); } while (false)

View File

@ -117,11 +117,15 @@ void print_backtrace(FILE* out, char const* label) {}
#endif #endif
#if TORRENT_PRODUCTION_ASSERTS
char const* libtorrent_assert_log = "asserts.log";
#endif
void assert_fail(char const* expr, int line, char const* file, char const* function) void assert_fail(char const* expr, int line, char const* file, char const* function)
{ {
#if TORRENT_PRODUCTION_ASSERTS #if TORRENT_PRODUCTION_ASSERTS
FILE* out = fopen("asserts.log", "a+"); FILE* out = fopen(libtorrent_assert_log, "a+");
if (out == 0) out = stderr; if (out == 0) out = stderr;
#else #else
FILE* out = stderr; FILE* out = stderr;