18 #ifndef _LOG4CXX_SPI_LOCATION_LOCATIONINFO_H
19 #define _LOG4CXX_SPI_LOCATION_LOCATIONINFO_H
21 #include <log4cxx/log4cxx.h>
24 #if __cpp_lib_string_view || (_MSVC_LANG >= 201703L)
25 #include <string_view>
26 #define LOG4CXX_HAS_STRING_VIEW
32 #define LOG4CXX_SHORT_FILENAME_SPLIT_CHAR '\\'
34 #define LOG4CXX_SHORT_FILENAME_SPLIT_CHAR '/'
55 static const char*
const NA;
60 #ifdef LOG4CXX_HAS_STRING_VIEW
61 static constexpr
const char* calcShortFileName(
const char* fileName){
62 std::string_view view(fileName);
70 return location ==
nullptr ? fileName : location + 1;
80 const char*
const shortFileName,
81 const char*
const functionName,
138 const char* fileName;
141 const char* shortFileName;
144 const char* methodName;
151 #if !defined(LOG4CXX_LOCATION) && !LOG4CXX_DISABLE_LOCATION_INFO
152 #if defined(_MSC_VER)
154 #define __LOG4CXX_FUNC__ __FUNCSIG__
157 #if defined(__GNUC__)
158 #define __LOG4CXX_FUNC__ __PRETTY_FUNCTION__
160 #if defined(__BORLANDC__)
161 #define __LOG4CXX_FUNC__ __FUNC__
165 #if !defined(__LOG4CXX_FUNC__)
166 #define __LOG4CXX_FUNC__ ""
170 #define LOG4CXX_LOCATION ::log4cxx::spi::LocationInfo(__FILE__, \
171 ::log4cxx::spi::LocationInfo::calcShortFileName(__FILE__), \
176 #define LOG4CXX_LOCATION ::log4cxx::spi::LocationInfo::getLocationUnavailable()
This class represents the location of a logging statement.
Definition: locationinfo.h:46
LocationInfo(const LocationInfo &src)
Copy constructor.
static const char * calcShortFileName(const char *fileName)
Definition: locationinfo.h:68
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:56
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:55
#define LOG4CXX_SHORT_FILENAME_SPLIT_CHAR
Definition: locationinfo.h:34
Definition: appender.h:27