fixes logging of absolute paths in ucx_logger_logf()

Fri, 20 Dec 2019 14:44:50 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 20 Dec 2019 14:44:50 +0100
changeset 376
028039652b86
parent 375
460c0258bb5b
child 377
2099a3aff61e

fixes logging of absolute paths in ucx_logger_logf()

src/logging.c file | annotate | diff | comparison | revisions
src/ucx/logging.h file | annotate | diff | comparison | revisions
     1.1 --- a/src/logging.c	Fri Dec 20 14:29:41 2019 +0100
     1.2 +++ b/src/logging.c	Fri Dec 20 14:44:50 2019 +0100
     1.3 @@ -91,6 +91,10 @@
     1.4              k += strftime(msg+k, 128, logger->dateformat, localtime(&now));
     1.5          }
     1.6          if ((logger->mask & UCX_LOGGER_SOURCE) > 0) {
     1.7 +            char *fpart = strrchr(file, '/');
     1.8 +            if (fpart) file = fpart+1;
     1.9 +            fpart = strrchr(file, '\\');
    1.10 +            if (fpart) file = fpart+1;
    1.11              n = strlen(file);
    1.12              memcpy(msg+k, file, n);
    1.13              k += n;
     2.1 --- a/src/ucx/logging.h	Fri Dec 20 14:29:41 2019 +0100
     2.2 +++ b/src/ucx/logging.h	Fri Dec 20 14:44:50 2019 +0100
     2.3 @@ -160,7 +160,10 @@
     2.4   * format is:
     2.5   * 
     2.6   * <code>[LEVEL] [TIMESTAMP] [SOURCEFILE]:[LINENO] message</code>
     2.7 - * 
     2.8 + *
     2.9 + * The source file name is reduced to the actual file name. This is necessary to
    2.10 + * get consistent behavior over different definitions of the __FILE__ macro.
    2.11 + *
    2.12   * <b>Attention:</b> the message (including automatically generated information)
    2.13   * is limited to 4096 characters. The level description is limited to
    2.14   * 256 characters and the timestamp string is limited to 128 characters.

mercurial