mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 03:33:28 +08:00
Merge pull request #22924 from alalek:logger_strip_base_dir
core(logger): strip opencv's modules base path
This commit is contained in:
commit
1788c93aea
@ -233,24 +233,42 @@ void writeLogMessage(LogLevel logLevel, const char* message)
|
|||||||
(*out) << std::flush;
|
(*out) << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* stripSourceFilePathPrefix(const char* file)
|
||||||
|
{
|
||||||
|
CV_Assert(file);
|
||||||
|
const char* pos = file;
|
||||||
|
const char* strip_pos = NULL;
|
||||||
|
char ch = 0;
|
||||||
|
while ((ch = pos[0]) != 0)
|
||||||
|
{
|
||||||
|
++pos;
|
||||||
|
if (ch == '/' || ch == '\\')
|
||||||
|
strip_pos = pos;
|
||||||
|
}
|
||||||
|
if (strip_pos == NULL || strip_pos == pos/*eos*/)
|
||||||
|
return file;
|
||||||
|
return strip_pos;
|
||||||
|
}
|
||||||
|
|
||||||
void writeLogMessageEx(LogLevel logLevel, const char* tag, const char* file, int line, const char* func, const char* message)
|
void writeLogMessageEx(LogLevel logLevel, const char* tag, const char* file, int line, const char* func, const char* message)
|
||||||
{
|
{
|
||||||
std::ostringstream strm;
|
std::ostringstream strm;
|
||||||
if (tag)
|
if (tag)
|
||||||
{
|
{
|
||||||
strm << tag << " ";
|
strm << tag << ' ';
|
||||||
}
|
}
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
strm << file << " ";
|
strm << stripSourceFilePathPrefix(file);
|
||||||
}
|
if (line > 0)
|
||||||
if (line > 0)
|
{
|
||||||
{
|
strm << ':' << line;
|
||||||
strm << "(" << line << ") ";
|
}
|
||||||
|
strm << ' ';
|
||||||
}
|
}
|
||||||
if (func)
|
if (func)
|
||||||
{
|
{
|
||||||
strm << func << " ";
|
strm << func << ' ';
|
||||||
}
|
}
|
||||||
strm << message;
|
strm << message;
|
||||||
writeLogMessage(logLevel, strm.str().c_str());
|
writeLogMessage(logLevel, strm.str().c_str());
|
||||||
|
Loading…
Reference in New Issue
Block a user