Skip to content

Commit

Permalink
Custom namespace support
Browse files Browse the repository at this point in the history
  • Loading branch information
vopl committed Oct 29, 2023
1 parent 794f55e commit 20f4433
Show file tree
Hide file tree
Showing 495 changed files with 1,891 additions and 1,862 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ if(UNIX)
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set(VERSION "${log4cxx_VERSION_MAJOR}.${log4cxx_VERSION_MINOR}.${log4cxx_VERSION_PATCH}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/liblog4cxx-qt.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/liblog4cxx-qt.pc"
"${CMAKE_CURRENT_BINARY_DIR}/liblog4cxx-qt.pc"
)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblog4cxx-qt.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif(LOG4CXX_QT_SUPPORT)
endif(UNIX)

Expand Down Expand Up @@ -286,8 +286,10 @@ message(STATUS " C++ compiler .................... : ${CMAKE_CXX_COMPILER}")
message(STATUS " C++ features requested: ......... : ${CMAKE_CXX_STANDARD}")
message(STATUS " Build shared library ............ : ${BUILD_SHARED_LIBS}")
message(STATUS " Build tests ..................... : ${BUILD_TESTING}")
message(STATUS " Build examples................... : ${BUILD_EXAMPLES}")
message(STATUS " Build site ...................... : ${BUILD_SITE}")
message(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
message(STATUS " log4cxx namespace ............... : ${LOG4CXX_NS}")
message(STATUS " log4cxx char API ................ : ON")
message(STATUS " log4cxx wchar API ............... : ${LOG4CXX_WCHAR_T}")
if(STD_LIB_HAS_UNICODE_STRING)
Expand Down
16 changes: 12 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@ if(HAS_LIBESMTP)
target_link_libraries(log4cxx PRIVATE ${ESMTP_LIBRARIES})
endif()
if(HAS_ODBC)
target_include_directories(log4cxx PRIVATE ${ODBC_INCLUDE_DIR})
target_link_libraries( log4cxx PRIVATE ${ODBC_LIBRARIES})
target_include_directories(log4cxx PRIVATE ${ODBC_INCLUDE_DIR})
target_link_libraries( log4cxx PRIVATE ${ODBC_LIBRARIES})
endif(HAS_ODBC)

if(BUILD_TESTING)
add_subdirectory(test)
add_subdirectory(examples/cpp)
add_subdirectory(test)
endif()

option(BUILD_EXAMPLES "Build log4cxx examples" ${BUILD_TESTING})
if(BUILD_EXAMPLES)
if("log4cxx" STREQUAL "${LOG4CXX_NS}")
add_subdirectory(examples/cpp)
else()
message(FATAL_ERROR "Examples can only be build if LOG4CXX_NS=log4cxx, but LOG4CXX_NS=${LOG4CXX_NS}.")
endif()
endif()

add_subdirectory(site)
10 changes: 5 additions & 5 deletions src/cmake/boost-fallback/boost-fallback.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ try_compile(STD_EXPERIMENTAL_FILESYSTEM_FOUND "${CMAKE_BINARY_DIR}/boost-fallbac
"${CMAKE_CURRENT_LIST_DIR}/test-stdexpfilesystem.cpp")

# Check for standard headers that we need, fall back to boost if they're not found
set(NAMESPACE_ALIAS log4cxx)
set(NAMESPACE_ALIAS ${LOG4CXX_NS})
option(PREFER_BOOST "Prefer Boost over std:: equivalents" OFF)

if( ${PREFER_BOOST} OR NOT ( ${STD_FILESYSTEM_FOUND} OR ${STD_EXPERIMENTAL_FILESYSTEM_FOUND} ) )
Expand All @@ -24,13 +24,13 @@ if( ${PREFER_BOOST} OR NOT ( ${STD_FILESYSTEM_FOUND} OR ${STD_EXPERIMENTAL_FILES
endif()

if( ${STD_FILESYSTEM_FOUND} AND NOT ${PREFER_BOOST} )
set( FILESYSTEM_IMPL "std::filesystem" )
set( FILESYSTEM_IMPL "std::filesystem" )
elseif( ${STD_EXPERIMENTAL_FILESYSTEM_FOUND} AND NOT ${PREFER_BOOST} )
set( FILESYSTEM_IMPL "std::experimental::filesystem" )
set( FILESYSTEM_IMPL "std::experimental::filesystem" )
elseif( ${Boost_FILESYSTEM_FOUND} )
set( FILESYSTEM_IMPL "boost::filesystem" )
set( FILESYSTEM_IMPL "boost::filesystem" )
else()
set( FILESYSTEM_IMPL "NONE" )
set( FILESYSTEM_IMPL "NONE" )
endif()


2 changes: 1 addition & 1 deletion src/cmake/win32_target_environment_path.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function(get_target_environment_path varName)
set(NORMAL_PATH $ENV{PATH})
set(ESCAPED_PATH "")
foreach( ENTRY ${PATH_FOR_TESTS}${NORMAL_PATH} )
set(ESCAPED_PATH "${ESCAPED_PATH}${ENTRY}\\\;")
set(ESCAPED_PATH "${ESCAPED_PATH}${ENTRY}\\\;")
endforeach()
set(${varName} ${ESCAPED_PATH} PARENT_SCOPE)
endfunction()
6 changes: 3 additions & 3 deletions src/main/cpp-qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ if(LOG4CXX_QT_SUPPORT)

add_library(log4cxx-qt)
if(BUILD_SHARED_LIBS)
target_compile_definitions(log4cxx-qt PRIVATE LOG4CXX)
target_compile_definitions(log4cxx-qt PRIVATE LOG4CXX)
else()
target_compile_definitions(log4cxx-qt PUBLIC LOG4CXX_STATIC)
target_compile_definitions(log4cxx-qt PUBLIC LOG4CXX_STATIC)
endif()
add_dependencies(log4cxx-qt configure_log4cxx)
target_compile_definitions(log4cxx-qt PRIVATE "QT_NO_KEYWORDS")
target_link_libraries(log4cxx-qt Qt5::Core log4cxx)
target_sources(log4cxx-qt
PRIVATE
messagehandler.cpp
configuration.cpp
configuration.cpp
)
set_target_properties(log4cxx-qt PROPERTIES
VERSION ${LIBLOG4CXX_LIB_VERSION}
Expand Down
26 changes: 13 additions & 13 deletions src/main/cpp-qt/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
#include <memory>
#include <QDebug>

namespace log4cxx
namespace LOG4CXX_NS
{
namespace qt
{
using log4cxx::helpers::LogLog;
using LOG4CXX_NS::helpers::LogLog;

static std::unique_ptr<QFileSystemWatcher> watcher;
static QString configFilename;
Expand All @@ -40,15 +40,15 @@ static void loadXMLFile(const QString& path){
if(!fi.exists()){
return;
}
log4cxx::xml::DOMConfigurator::configure(path.toStdString());
LOG4CXX_NS::xml::DOMConfigurator::configure(path.toStdString());
}

static void loadPropertiesFile(const QString& path){
QFileInfo fi(configFilename);
if(!fi.exists()){
return;
}
log4cxx::PropertyConfigurator::configure(path.toStdString());
LOG4CXX_NS::PropertyConfigurator::configure(path.toStdString());
}

static void dirChanged(const QString&){
Expand All @@ -68,18 +68,18 @@ static void dirChanged(const QString&){

Configuration::Configuration(){}

log4cxx::spi::ConfigurationStatus Configuration::tryLoadFile(const QString& filename){
log4cxx::spi::ConfigurationStatus stat =log4cxx::spi::ConfigurationStatus::NotConfigured;
LOG4CXX_NS::spi::ConfigurationStatus Configuration::tryLoadFile(const QString& filename){
LOG4CXX_NS::spi::ConfigurationStatus stat =LOG4CXX_NS::spi::ConfigurationStatus::NotConfigured;
bool isXML = false;

if(filename.endsWith(".xml")){
stat = log4cxx::xml::DOMConfigurator::configure(filename.toStdString());
stat = LOG4CXX_NS::xml::DOMConfigurator::configure(filename.toStdString());
isXML = true;
}else if(filename.endsWith(".properties")){
stat = log4cxx::PropertyConfigurator::configure(filename.toStdString());
stat = LOG4CXX_NS::PropertyConfigurator::configure(filename.toStdString());
}

if( stat == log4cxx::spi::ConfigurationStatus::Configured ){
if( stat == LOG4CXX_NS::spi::ConfigurationStatus::Configured ){
watcher = std::make_unique<QFileSystemWatcher>();
configFilename = filename;
QFileInfo fi(filename);
Expand All @@ -100,7 +100,7 @@ log4cxx::spi::ConfigurationStatus Configuration::tryLoadFile(const QString& file
return stat;
}

std::tuple<log4cxx::spi::ConfigurationStatus,QString>
std::tuple<LOG4CXX_NS::spi::ConfigurationStatus,QString>
Configuration::configureFromFileAndWatch(const QVector<QString>& directories,
const QVector<QString>& filenames){
for( QString dir : directories ){
Expand All @@ -112,8 +112,8 @@ Configuration::configureFromFileAndWatch(const QVector<QString>& directories,
LogLog::debug(msg);
if (candidate.exists())
{
log4cxx::spi::ConfigurationStatus configStatus = tryLoadFile(canidate_str);
if( configStatus == log4cxx::spi::ConfigurationStatus::Configured ){
LOG4CXX_NS::spi::ConfigurationStatus configStatus = tryLoadFile(canidate_str);
if( configStatus == LOG4CXX_NS::spi::ConfigurationStatus::Configured ){
return {configStatus, canidate_str};
}
LOG4CXX_DECODE_QSTRING(failmsg, "Unable to load " + canidate_str + ": trying next");
Expand All @@ -122,7 +122,7 @@ Configuration::configureFromFileAndWatch(const QVector<QString>& directories,
}
}

return {log4cxx::spi::ConfigurationStatus::NotConfigured, QString()};
return {LOG4CXX_NS::spi::ConfigurationStatus::NotConfigured, QString()};
}

} //namespace helpers
Expand Down
8 changes: 4 additions & 4 deletions src/main/cpp-qt/messagehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
#include <log4cxx/logger.h>
#include <log4cxx/spi/location/locationinfo.h>

namespace log4cxx {
namespace LOG4CXX_NS {
namespace qt {

void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message )
{
log4cxx::LoggerPtr qtLogger = log4cxx::Logger::getLogger( context.category );
log4cxx::spi::LocationInfo location( context.file,
log4cxx::spi::LocationInfo::calcShortFileName(context.file),
LOG4CXX_NS::LoggerPtr qtLogger = LOG4CXX_NS::Logger::getLogger( context.category );
LOG4CXX_NS::spi::LocationInfo location( context.file,
LOG4CXX_NS::spi::LocationInfo::calcShortFileName(context.file),
context.function,
context.line );

Expand Down
50 changes: 27 additions & 23 deletions src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,33 @@ set(extra_classes "")

if(LOG4CXX_NETWORKING_SUPPORT)
list(APPEND extra_classes
datagrampacket.cpp
datagramsocket.cpp
aprdatagramsocket.cpp
serversocket.cpp
aprserversocket.cpp
socket.cpp
aprsocket.cpp
telnetappender.cpp
socketappenderskeleton.cpp
socketoutputstream.cpp
xmlsocketappender.cpp
syslogwriter.cpp
syslogappender.cpp
)
datagrampacket.cpp
datagramsocket.cpp
aprdatagramsocket.cpp
serversocket.cpp
aprserversocket.cpp
socket.cpp
aprsocket.cpp
telnetappender.cpp
socketappenderskeleton.cpp
socketoutputstream.cpp
xmlsocketappender.cpp
syslogwriter.cpp
syslogappender.cpp
)
endif()

if(LOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER)
target_compile_definitions(log4cxx PRIVATE LOG4CXX_MULTI_PROCESS)
list(APPEND extra_classes
multiprocessrollingfileappender.cpp
)
multiprocessrollingfileappender.cpp
)
endif()

if(${ENABLE_FMT_LAYOUT})
list(APPEND extra_classes
fmtlayout.cpp
)
fmtlayout.cpp
)
endif()

target_sources(log4cxx
Expand Down Expand Up @@ -224,6 +224,10 @@ if(${ENABLE_FMT_LAYOUT})
endif()

if(LOG4CXX_ABI_CHECK)
if(NOT "log4cxx" STREQUAL "${LOG4CXX_NS}")
message(FATAL_ERROR "ABI compatability can only be checked if LOG4CXX_NS=log4cxx, but LOG4CXX_NS=${LOG4CXX_NS}.")
endif()

message("Getting dependencies for ABI compatability check...")
# Get the latest version of abi-dumper and abi-compliance-checker
include(FetchContent)
Expand All @@ -250,11 +254,11 @@ if(LOG4CXX_ABI_CHECK)

add_custom_target(dump-abi ALL
COMMAND perl ${abi-dumper-script} -o new-abi.dump -skip-cxx -vnum ${log4cxx_ABI_VER} $<TARGET_FILE:log4cxx>
DEPENDS log4cxx
COMMENT "Dumping ABI symbols")
DEPENDS log4cxx
COMMENT "Dumping ABI symbols")

add_custom_target(compare-abi ALL
COMMAND perl ${abi-compliance-script} -skip-internal-symbols "\\d\\(fmt\\)" -skip-internal-types "\\(fmt\\)::" -l log4cxx -old ${LOG4CXX_SOURCE_DIR}/src/main/abi-symbols/abi.dump -new new-abi.dump
DEPENDS dump-abi
COMMENT "Comparing ABI symbols")
COMMAND perl ${abi-compliance-script} -skip-internal-symbols "\\d\\(fmt\\)" -skip-internal-types "\\(fmt\\)::" -l log4cxx -old ${LOG4CXX_SOURCE_DIR}/src/main/abi-symbols/abi.dump -new new-abi.dump
DEPENDS dump-abi
COMMENT "Comparing ABI symbols")
endif(LOG4CXX_ABI_CHECK)
8 changes: 4 additions & 4 deletions src/main/cpp/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include <mutex>
#include <memory>

using namespace log4cxx;
using namespace log4cxx::rolling;
using namespace log4cxx::helpers;
using namespace LOG4CXX_NS;
using namespace LOG4CXX_NS::rolling;
using namespace LOG4CXX_NS::helpers;

IMPLEMENT_LOG4CXX_OBJECT(Action)

Expand All @@ -41,7 +41,7 @@ Action::~Action()
/**
* {@inheritDoc}
*/
void Action::run(log4cxx::helpers::Pool& pool1)
void Action::run(LOG4CXX_NS::helpers::Pool& pool1)
{
std::unique_lock<std::mutex> lock(m_priv->mutex);

Expand Down
12 changes: 6 additions & 6 deletions src/main/cpp/andfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include <log4cxx/helpers/optionconverter.h>
#include <log4cxx/private/filter_priv.h>

using namespace log4cxx;
using namespace log4cxx::filter;
using namespace log4cxx::spi;
using namespace log4cxx::helpers;
using namespace LOG4CXX_NS;
using namespace LOG4CXX_NS::filter;
using namespace LOG4CXX_NS::spi;
using namespace LOG4CXX_NS::helpers;

#define priv static_cast<AndFilterPrivate*>(m_priv.get())

Expand All @@ -35,8 +35,8 @@ struct AndFilter::AndFilterPrivate : public FilterPrivate
tailFilter(),
acceptOnMatch(true) {}

log4cxx::spi::FilterPtr headFilter;
log4cxx::spi::FilterPtr tailFilter;
LOG4CXX_NS::spi::FilterPtr headFilter;
LOG4CXX_NS::spi::FilterPtr tailFilter;
bool acceptOnMatch;
};

Expand Down
6 changes: 3 additions & 3 deletions src/main/cpp/appenderattachableimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include <log4cxx/helpers/pool.h>
#include <mutex>

using namespace log4cxx;
using namespace log4cxx::helpers;
using namespace log4cxx::spi;
using namespace LOG4CXX_NS;
using namespace LOG4CXX_NS::helpers;
using namespace LOG4CXX_NS::spi;

IMPLEMENT_LOG4CXX_OBJECT(AppenderAttachableImpl)

Expand Down
6 changes: 3 additions & 3 deletions src/main/cpp/appenderskeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include <log4cxx/private/appenderskeleton_priv.h>
#include <mutex>

using namespace log4cxx;
using namespace log4cxx::spi;
using namespace log4cxx::helpers;
using namespace LOG4CXX_NS;
using namespace LOG4CXX_NS::spi;
using namespace LOG4CXX_NS::helpers;

IMPLEMENT_LOG4CXX_OBJECT(AppenderSkeleton)

Expand Down
2 changes: 1 addition & 1 deletion src/main/cpp/aprdatagramsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <log4cxx/helpers/transcoder.h>
#include <apr_network_io.h>

namespace log4cxx
namespace LOG4CXX_NS
{
namespace helpers
{
Expand Down
6 changes: 3 additions & 3 deletions src/main/cpp/aprinitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#include <log4cxx/helpers/filewatchdog.h>
#include <log4cxx/helpers/date.h>

using namespace log4cxx::helpers;
using namespace log4cxx;
using namespace LOG4CXX_NS::helpers;
using namespace LOG4CXX_NS;

bool APRInitializer::isDestructed = false;

Expand All @@ -52,7 +52,7 @@ struct APRInitializer::APRInitializerPrivate{

namespace
{
extern "C" void tlsDestruct(void* ptr)
void tlsDestruct(void* ptr)
{
delete ((ThreadSpecificData*) ptr);
}
Expand Down
Loading

0 comments on commit 20f4433

Please sign in to comment.