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:
parent
eae54b67d8
commit
2b3b486a37
@ -1,5 +1,6 @@
|
||||
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.
|
||||
Fix tests for failing dm_snprintf() in stats code.
|
||||
Parsing mirror status accepts 'userspace' keyword in status.
|
||||
|
@ -108,12 +108,12 @@ void dm_lib_init(void)
|
||||
*/
|
||||
|
||||
__attribute__((format(printf, 5, 0)))
|
||||
static void _default_log_line(int level,
|
||||
const char *file __attribute__((unused)),
|
||||
int line __attribute__((unused)), int dm_errno_or_class,
|
||||
static void _default_log_line(int level, const char *file,
|
||||
int line, int dm_errno_or_class,
|
||||
const char *f, va_list ap)
|
||||
{
|
||||
static int _abort_on_internal_errors = -1;
|
||||
static int _debug_with_line_numbers = -1;
|
||||
FILE *out = log_stderr(level) ? stderr : stdout;
|
||||
|
||||
level = log_level(level);
|
||||
@ -121,6 +121,15 @@ static void _default_log_line(int level,
|
||||
if (level <= _LOG_WARN || _verbose) {
|
||||
if (level < _LOG_WARN)
|
||||
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);
|
||||
fputc('\n', out);
|
||||
}
|
||||
|
@ -481,6 +481,9 @@ Abort processing if the code detects a non-fatal internal error.
|
||||
.B DM_DISABLE_UDEV
|
||||
Avoid interaction with udev. LVM will manage the relevant nodes in /dev
|
||||
directly.
|
||||
.TP
|
||||
.B DM_DEBUG_WITH_LINE_NUMBERS
|
||||
Prepends source file name and code line number with libdm debugging.
|
||||
.
|
||||
.SH FILES
|
||||
.
|
||||
|
Loading…
Reference in New Issue
Block a user