diff options
Diffstat (limited to 'recipes-containers/lxc/files/logs-optionally-use-base-filenames-to-report-src-fil.patch')
-rw-r--r-- | recipes-containers/lxc/files/logs-optionally-use-base-filenames-to-report-src-fil.patch | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/recipes-containers/lxc/files/logs-optionally-use-base-filenames-to-report-src-fil.patch b/recipes-containers/lxc/files/logs-optionally-use-base-filenames-to-report-src-fil.patch new file mode 100644 index 00000000..583b6f1c --- /dev/null +++ b/recipes-containers/lxc/files/logs-optionally-use-base-filenames-to-report-src-fil.patch | |||
@@ -0,0 +1,70 @@ | |||
1 | From 4729d0f4c4d1dacd150ddfd7061dda875eb94e34 Mon Sep 17 00:00:00 2001 | ||
2 | Message-Id: <4729d0f4c4d1dacd150ddfd7061dda875eb94e34.1443216870.git.Jim.Somerville@windriver.com> | ||
3 | From: Jim Somerville <Jim.Somerville@windriver.com> | ||
4 | Date: Fri, 25 Sep 2015 15:08:17 -0400 | ||
5 | Subject: [PATCH 1/1] logs: optionally use base filenames to report src files | ||
6 | |||
7 | Problem: Logs are nice in that they report the source file, | ||
8 | routine, and line number where an issue occurs. But the | ||
9 | file is printed as the absolute filename. Users do not | ||
10 | need to see a long spew of path directory names where the package | ||
11 | was built. It just confuses things. | ||
12 | |||
13 | Solution: Optionally chop off all leading directories so that just | ||
14 | the source filename ie. basename is printed. This is done by | ||
15 | setting a #ifdef LXC_LOG_USE_BASENAME check in the code. That | ||
16 | define is done via the optional --enable-log-src-basename provided | ||
17 | at configure time. | ||
18 | |||
19 | Using __BASE_FILE__ instead of __FILE__ did not work. It | ||
20 | refers to the file name as presented to the compile | ||
21 | machinery, and that may still be the absolute pathname to | ||
22 | the file. | ||
23 | |||
24 | Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com> | ||
25 | --- | ||
26 | configure.ac | 9 +++++++++ | ||
27 | src/lxc/log.h | 5 +++++ | ||
28 | 2 files changed, 14 insertions(+) | ||
29 | |||
30 | diff --git a/configure.ac b/configure.ac | ||
31 | index deba90b..c1ed67b 100644 | ||
32 | --- a/configure.ac | ||
33 | +++ b/configure.ac | ||
34 | @@ -357,6 +357,15 @@ AM_COND_IF([ENABLE_PYTHON], | ||
35 | PKG_CHECK_MODULES([PYTHONDEV], [python3 >= 3.2],[],[AC_MSG_ERROR([You must install python3-dev])]) | ||
36 | AC_DEFINE_UNQUOTED([ENABLE_PYTHON], 1, [Python3 is available])]) | ||
37 | |||
38 | +# Enable basenames in the logs for source files | ||
39 | +AC_ARG_ENABLE([log-src-basename], | ||
40 | + [AC_HELP_STRING([--enable-log-src-basename], [Use the shorter source file basename in the logs [default=no]])], | ||
41 | + [], [enable_log_src_basename=no]) | ||
42 | + | ||
43 | +if test "x$enable_log_src_basename" = "xyes"; then | ||
44 | + AC_DEFINE([LXC_LOG_USE_BASENAME], 1, [Enabling shorter src filenames in the logs]) | ||
45 | +fi | ||
46 | + | ||
47 | # Enable dumping stack traces | ||
48 | AC_ARG_ENABLE([mutex-debugging], | ||
49 | [AC_HELP_STRING([--enable-mutex-debugging], [Makes mutexes to report error and provide stack trace [default=no]])], | ||
50 | diff --git a/src/lxc/log.h b/src/lxc/log.h | ||
51 | index 76bd4df..4365977 100644 | ||
52 | --- a/src/lxc/log.h | ||
53 | +++ b/src/lxc/log.h | ||
54 | @@ -74,8 +74,13 @@ struct lxc_log_locinfo { | ||
55 | int line; | ||
56 | }; | ||
57 | |||
58 | +#ifdef LXC_LOG_USE_BASENAME | ||
59 | +#define LXC_LOG_LOCINFO_INIT \ | ||
60 | + { .file = (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), .func = __func__, .line = __LINE__ } | ||
61 | +#else | ||
62 | #define LXC_LOG_LOCINFO_INIT \ | ||
63 | { .file = __FILE__, .func = __func__, .line = __LINE__ } | ||
64 | +#endif | ||
65 | |||
66 | /* brief logging event object */ | ||
67 | struct lxc_log_event { | ||
68 | -- | ||
69 | 1.8.3.2 | ||
70 | |||