Change in libosmocore[master]: logging: Use __BASE_FILE__ instead of __FILE__

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

gerrit-no-reply at lists.osmocom.org gerrit-no-reply at lists.osmocom.org
Tue May 10 13:29:02 UTC 2016


>From Harald Welte <laforge at gnumonks.org>:

Harald Welte has uploaded a new change for review.

  https://gerrit.osmocom.org/38

Change subject: logging: Use __BASE_FILE__ instead of __FILE__
......................................................................

logging: Use __BASE_FILE__ instead of __FILE__

Apparently __FILE__ expands to nasty '../../..' paths when BUILDDIR !=
SRCDIR.  This in turn leads to ugly log lines like:

<0000> ../../../../osmo-bts/src/common/rsl.c:1642 (bts=0,trx=0,ts=0,ss=0) Handing RLL msg UNIT_DATA_IND from LAPDm to MEAS REP

Where we certainly wouldn't want the "../../../../osmo-bts" part.

Change-Id: If6d2de33c3b6bb2943954bbd81eff261dc279d58
---
M include/osmocom/core/logging.h
M include/osmocom/core/utils.h
2 files changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/38/38/1

diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index e51487b..c3b3eb5 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -22,13 +22,13 @@
 #define DEBUGP(ss, fmt, args...) \
 	do { \
 		if (log_check_level(ss, LOGL_DEBUG)) \
-			logp(ss, __FILE__, __LINE__, 0, fmt, ## args); \
+			logp(ss, __BASE_FILE__, __LINE__, 0, fmt, ## args); \
 	} while(0)
 
 #define DEBUGPC(ss, fmt, args...) \
 	do { \
 		if (log_check_level(ss, LOGL_DEBUG)) \
-			logp(ss, __FILE__, __LINE__, 1, fmt, ## args); \
+			logp(ss, __BASE_FILE__, __LINE__, 1, fmt, ## args); \
 	} while(0)
 
 #else
@@ -51,7 +51,7 @@
 #define LOGP(ss, level, fmt, args...) \
 	do { \
 		if (log_check_level(ss, level)) \
-			logp2(ss, level, __FILE__, __LINE__, 0, fmt, ##args); \
+			logp2(ss, level, __BASE_FILE__, __LINE__, 0, fmt, ##args); \
 	} while(0)
 
 /*! \brief Continue a log message through the Osmocom logging framework
@@ -63,7 +63,7 @@
 #define LOGPC(ss, level, fmt, args...) \
 	do { \
 		if (log_check_level(ss, level)) \
-			logp2(ss, level, __FILE__, __LINE__, 1, fmt, ##args); \
+			logp2(ss, level, __BASE_FILE__, __LINE__, 1, fmt, ##args); \
 	} while(0)
 
 /*! \brief different log levels */
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 205fa28..156be1b 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -55,7 +55,7 @@
 
 #define OSMO_ASSERT(exp)    \
 	if (!(exp)) { \
-		fprintf(stderr, "Assert failed %s %s:%d\n", #exp, __FILE__, __LINE__); \
+		fprintf(stderr, "Assert failed %s %s:%d\n", #exp, __BASE_FILE__, __LINE__); \
 		osmo_generate_backtrace(); \
 		abort(); \
 	}

-- 
To view, visit https://gerrit.osmocom.org/38
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If6d2de33c3b6bb2943954bbd81eff261dc279d58
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the OpenBSC mailing list