Project

General

Profile

Actions

Feature #2740

closed

shorten logging filenames when built outside of the source tree

Added by neels over 6 years ago. Updated over 5 years ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
-
Target version:
-
Start date:
12/12/2017
Due date:
% Done:

100%

Spec Reference:

Description

conversation from https://gerrit.osmocom.org/5265

Why do we see ../../../ in the file names? We switched logging to __BASE_FILE__ to avoid this on src vs.  build dir builds..

I have no idea, maybe __BASE_FILE__ isn't working out as expected? I build in this dir topology and usually see the long ../../ paths:

  ./src/osmo-foo/configure.ac
  ./make/osmo-foo/Makefile

Can confirm though that LOGP macros use __BASE_FILE__.

"__BASE_FILE__

    This macro expands to the name of the main input file, in the form of a C string constant. This is the source file that was specified on the command line of the preprocessor or C compiler.
" 

So it's not related to stripping path elements. If we did something like 'cd $(srcdir); gcc -o $(builddir)/thing.o' the paths would go shorter. I'm not so sure on when __BASE_FILE__ != __FILE__, maybe we should go back to __FILE__?

stackoverflow has 

  #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)

which would iterate around in file paths for each log statement. compared to terminal output that's probably neglectable.
Actions #1

Updated by laforge over 5 years ago

  • Assignee set to neels
  • % Done changed from 0 to 100
Actions #2

Updated by neels over 5 years ago

  • % Done changed from 100 to 90

(apologies, somehow this must've slipped by my issue sweeps for a long time.)

We have 'logging print file basename' for a long time now, so the shortened file name feature is pretty much resolved.

But still, we should not use BASE_FILE, which only coincidentally is the same file name that we expect to see. If we had a function that logs and that was defined in an included file, BASE_FILE would indicate the first file where the #include is, and not the file where the function is defined. BASE_FILE works because we don't ever include function definitions that log something, so BASE_FILE always coincides with FILE for our logging; but still BASE_FILE is semantically the wrong constant.

https://gerrit.osmocom.org/#/c/libosmocore/+/10537
https://gerrit.osmocom.org/#/c/osmo-bsc/+/10538
https://gerrit.osmocom.org/#/c/osmo-msc/+/10539
https://gerrit.osmocom.org/#/c/osmo-sgsn/+/10540

Actions #3

Updated by neels over 5 years ago

  • Status changed from New to In Progress
Actions #4

Updated by neels over 5 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 90 to 100

merged.

Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)