1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

libdm: support for DM_DEBUG_WITH_LINE_NUMBERS

For any libdm tool using default debugging function allow
to show source filename and code line number when this
functionality is available.
This commit is contained in:
Zdenek Kabelac 2018-03-14 18:08:16 +01:00
parent eae54b67d8
commit 2b3b486a37
3 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.147 - Version 1.02.147 -
===================================== =====================================
Support DM_DEBUG_WITH_LINE_NUMBERS envvar for debug msg with source:line.
Configured command for thin pool threshold handling gets whole environment. Configured command for thin pool threshold handling gets whole environment.
Fix tests for failing dm_snprintf() in stats code. Fix tests for failing dm_snprintf() in stats code.
Parsing mirror status accepts 'userspace' keyword in status. Parsing mirror status accepts 'userspace' keyword in status.

View File

@ -108,12 +108,12 @@ void dm_lib_init(void)
*/ */
__attribute__((format(printf, 5, 0))) __attribute__((format(printf, 5, 0)))
static void _default_log_line(int level, static void _default_log_line(int level, const char *file,
const char *file __attribute__((unused)), int line, int dm_errno_or_class,
int line __attribute__((unused)), int dm_errno_or_class,
const char *f, va_list ap) const char *f, va_list ap)
{ {
static int _abort_on_internal_errors = -1; static int _abort_on_internal_errors = -1;
static int _debug_with_line_numbers = -1;
FILE *out = log_stderr(level) ? stderr : stdout; FILE *out = log_stderr(level) ? stderr : stdout;
level = log_level(level); level = log_level(level);
@ -121,6 +121,15 @@ static void _default_log_line(int level,
if (level <= _LOG_WARN || _verbose) { if (level <= _LOG_WARN || _verbose) {
if (level < _LOG_WARN) if (level < _LOG_WARN)
out = stderr; out = stderr;
if (_debug_with_line_numbers < 0)
/* Set when env DM_DEBUG_WITH_LINE_NUMBERS is not "0" */
_debug_with_line_numbers =
strcmp(getenv("DM_DEBUG_WITH_LINE_NUMBERS") ? : "0", "0");
if (_debug_with_line_numbers)
fprintf(out, "%s:%d ", file, line);
vfprintf(out, f, ap); vfprintf(out, f, ap);
fputc('\n', out); fputc('\n', out);
} }

View File

@ -481,6 +481,9 @@ Abort processing if the code detects a non-fatal internal error.
.B DM_DISABLE_UDEV .B DM_DISABLE_UDEV
Avoid interaction with udev. LVM will manage the relevant nodes in /dev Avoid interaction with udev. LVM will manage the relevant nodes in /dev
directly. directly.
.TP
.B DM_DEBUG_WITH_LINE_NUMBERS
Prepends source file name and code line number with libdm debugging.
. .
.SH FILES .SH FILES
. .