From 80a95e1d9b7cdc8f178dac2f178c582b61da71e9 Mon Sep 17 00:00:00 2001 From: Harbour Date: Thu, 1 Nov 2007 13:10:04 +0200 Subject: [PATCH] Add source file:line_number to debug() --- F/F_Log.H | 12 +++++++++++- test/demo.C | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/F/F_Log.H b/F/F_Log.H index e9e1307..3e536f7 100644 --- a/F/F_Log.H +++ b/F/F_Log.H @@ -42,7 +42,17 @@ extern bool sigsegv_; #define dlog(x...) F::log(__PRETTY_FUNCTION__, INFO_LEVEL, ##x) #ifdef DEBUG_VERSION -#define debug(x...) F::log(__PRETTY_FUNCTION__, DEBUG_LEVEL, ##x) + +#define F_STRINGIFY(x) F_STRINGIFY_ARG(x) +#define F_STRINGIFY_ARG(x) (#x) + +#define debug(x...) do { std::string _prefix = __FILE__; \ + _prefix += ":"; \ + _prefix += F_STRINGIFY(__LINE__); \ + _prefix += ":"; \ + _prefix += __PRETTY_FUNCTION__; \ + F::log(_prefix.c_str(), DEBUG_LEVEL, ##x); } while(0) + #define bug() do { sigsegv_ = true; F::log(__PRETTY_FUNCTION__, FATAL_LEVEL, \ "*** Bug detected at %s:%d.", __FILE__, __LINE__); \ F::shutdown(-1); } while(0) diff --git a/test/demo.C b/test/demo.C index 2afa29f..8f6093d 100644 --- a/test/demo.C +++ b/test/demo.C @@ -28,6 +28,7 @@ void demo_app::main_loop() { ui()->beep(); ui()->progress_bar(); + debug("main loop called"); #ifdef TEST_SIGSEGV Thread::sleep(100); char *p = 0; -- 2.11.4.GIT