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