A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/log4cplus/log4cplus/issues/415 below:

Basename-pattern includes path in some logs · Issue #415 · log4cplus/log4cplus · GitHub

Hi together,

I'm happily using log4cplus for some years but now I just noticed, that loggers including %b in their pattern produce inconsistent output.

I'm for example using the pattern %n%p | %c | %b:%L%n%m%n and this creates the following exemplary log-file:

WARN | Misc.Hjson | Hjson.h:180
Creating new / missing configuration value 'Active'.

WARN | Misc.Hjson | d:\my\example\path\to\project\misc\hjson.h:180
Creating new / missing configuration value 'Freq'.

Obviously the path is included only in the second call, despite the fact that it's exactly the same template-function that is called from different places here.

Digging a little futher into this issue I found the function get_basename (const log4cplus::tstring& filename) in patternlayout.cxx combined with usage of different directory seperators in include-paths is the root cause. Changing the function to something like the following solves the issue for me:

static log4cplus::tstring
get_basename (const log4cplus::tstring& filename)
{
	log4cplus::tstring::size_type pos = filename.find_last_of(LOG4CPLUS_TEXT("\\/"));
    if (pos != log4cplus::tstring::npos)
        return filename.substr(pos+1);
    else
        return filename;
}

Obviously / is default seperator on unix-systems, while \\ is on Windows. Another solution would be to use the correct seperators in all #include-instructions. However I think log4cplus should not enforce this, especially since one can be using same headers for Windows and Unix targets...

Would my could snippet be a valid solution for integration into the library?

Best regards
Jan

Additional information on my system if needed:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4