Logger: Fix truncation of file names
Since the macro `__FILE__` **does not** always contain the full
filepath, the logger would sometimes produce messages that contain
incomplete file names such as:
> ugins/yaypeg/parser.hpp
.
@@ -134,10 +134,18 @@ static void replaceChars (char * str)
}
int elektraVLog (int level, const char * function, const char * absFile, int line, const char * mmsg, va_list args)
+{
+ const char * file;
+ if (absFile[0] == '/' || absFile[0] == '.')
{
size_t lenOfLogFileName = sizeof ("src/libs/elektra/log.c") - 1;
size_t lenOfLogPathName = strlen (__FILE__) - lenOfLogFileName;
- const char * file = &absFile[lenOfLogPathName];
+ file = &absFile[lenOfLogPathName];
+ }
+ else
+ {
+ file = absFile;
+ }
int ret = -1;
#ifndef NO_FILTER
