18 #ifndef _LOG4CXX_SPI_LOCATION_LOCATIONINFO_H
19 #define _LOG4CXX_SPI_LOCATION_LOCATIONINFO_H
21 #include <log4cxx/log4cxx.h>
26 #define LOG4CXX_SHORT_FILENAME_SPLIT_CHAR '\\'
28 #define LOG4CXX_SHORT_FILENAME_SPLIT_CHAR '/'
47 static const char*
const NA;
57 #if 201304L <= __cpp_constexpr
58 static constexpr
const char* calcShortFileName(
const char* fileName){
62 if (fileName ==
nullptr)
return nullptr;
65 const char* location =
nullptr;
66 for (
auto p = fileName; *p; ++p)
72 return location ==
nullptr ? fileName : location + 1;
81 const char*
const shortFileName,
82 const char*
const functionName,
139 const char* fileName;
142 const char* shortFileName;
145 const char* methodName;
152 #if !defined(LOG4CXX_LOCATION) && !LOG4CXX_DISABLE_LOCATION_INFO
153 #if defined(_MSC_VER)
155 #define __LOG4CXX_FUNC__ __FUNCSIG__
158 #if defined(__GNUC__)
159 #define __LOG4CXX_FUNC__ __PRETTY_FUNCTION__
161 #if defined(__BORLANDC__)
162 #define __LOG4CXX_FUNC__ __FUNC__
166 #if !defined(__LOG4CXX_FUNC__)
167 #define __LOG4CXX_FUNC__ nullptr
171 #define LOG4CXX_LOCATION ::LOG4CXX_NS::spi::LocationInfo(__FILE__, \
172 ::LOG4CXX_NS::spi::LocationInfo::calcShortFileName(__FILE__), \
177 #define LOG4CXX_LOCATION ::LOG4CXX_NS::spi::LocationInfo::getLocationUnavailable()
This class represents the location of a logging statement.
Definition: locationinfo.h:40
LocationInfo(const LocationInfo &src)
Copy constructor.
static const char * calcShortFileName(const char *fileName)
The part of fileName after the path.
Definition: locationinfo.h:60
void clear()
Resets location info to default state.
const std::string getClassName() const
Return the class name of the call site.
LocationInfo()
Default constructor.
LocationInfo(const char *const fileName, const char *const shortFileName, const char *const functionName, int lineNumber)
Constructor.
const char * getShortFileName() const
Return the short file name of the caller.
const char * getFileName() const
Return the file name of the caller.
const std::string getMethodName() const
Returns the method name of the caller.
static const char *const NA_METHOD
Definition: locationinfo.h:48
int getLineNumber() const
Returns the line number of the caller.
static const LocationInfo & getLocationUnavailable()
static const char *const NA
When location information is not available the constant NA is returned.
Definition: locationinfo.h:47
#define LOG4CXX_SHORT_FILENAME_SPLIT_CHAR
Definition: locationinfo.h:28