This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlog4cxx012.patch
91 lines (79 loc) · 3.37 KB
/
log4cxx012.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
From c9d161a6d946590bf808eb6006430c8c8d8b5cd6 Mon Sep 17 00:00:00 2001
From: Achmad Fathoni <fathoni.id@gmail.com>
Date: Sun, 15 Aug 2021 19:48:13 +0700
Subject: [PATCH] Fix for log4cxx 0.12.0
---
src/rosconsole/impl/rosconsole_log4cxx.cpp | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/rosconsole/impl/rosconsole_log4cxx.cpp b/src/rosconsole/impl/rosconsole_log4cxx.cpp
index 90183126..1d6f667b 100644
--- a/src/rosconsole/impl/rosconsole_log4cxx.cpp
+++ b/src/rosconsole/impl/rosconsole_log4cxx.cpp
@@ -127,6 +127,8 @@ class ROSConsoleStdioAppender : public log4cxx::AppenderSkeleton
}
};
+LOG4CXX_PTR_DEF(ROSConsoleStdioAppender);
+
void initialize()
{
// First set up some sane defaults programmatically.
@@ -166,7 +168,7 @@ void initialize()
}
log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME);
- logger->addAppender(new ROSConsoleStdioAppender);
+ logger->addAppender(ROSConsoleStdioAppenderPtr(new ROSConsoleStdioAppender()));
#ifdef _MSC_VER
if ( ros_root_cstr != NULL ) {
free(ros_root_cstr);
@@ -200,7 +202,7 @@ bool isEnabledFor(void* handle, ::ros::console::Level level)
void* getHandle(const std::string& name)
{
- return log4cxx::Logger::getLogger(name);
+ return log4cxx::Logger::getLogger(name).get();
}
std::string getName(void* handle)
@@ -216,7 +218,7 @@ std::string getName(void* handle)
bool get_loggers(std::map<std::string, levels::Level>& loggers)
{
- log4cxx::spi::LoggerRepositoryPtr repo = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME)->getLoggerRepository();
+ log4cxx::spi::LoggerRepositoryPtr repo = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME)->getLoggerRepository().lock();
log4cxx::LoggerList current_loggers = repo->getCurrentLoggers();
log4cxx::LoggerList::iterator it = current_loggers.begin();
@@ -352,20 +354,21 @@ class Log4cxxAppender : public log4cxx::AppenderSkeleton
ros::console::LogAppender* appender_;
};
+LOG4CXX_PTR_DEF(Log4cxxAppender);
Log4cxxAppender* g_log4cxx_appender = 0;
void register_appender(LogAppender* appender)
{
g_log4cxx_appender = new Log4cxxAppender(appender);
const log4cxx::LoggerPtr& logger = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME);
- logger->addAppender(g_log4cxx_appender);
+ logger->addAppender(Log4cxxAppenderPtr(g_log4cxx_appender));
}
void deregister_appender(LogAppender* appender){
if(g_log4cxx_appender->getAppender() == appender)
{
const log4cxx::LoggerPtr& logger = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME);
- logger->removeAppender(g_log4cxx_appender);
+ logger->removeAppender(Log4cxxAppenderPtr(g_log4cxx_appender));
delete g_log4cxx_appender;
g_log4cxx_appender = 0;
}
@@ -375,7 +378,7 @@ void shutdown()
if(g_log4cxx_appender)
{
const log4cxx::LoggerPtr& logger = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME);
- logger->removeAppender(g_log4cxx_appender);
+ logger->removeAppender(Log4cxxAppenderPtr(g_log4cxx_appender));
g_log4cxx_appender = 0;
}
// reset this so that the logger doesn't get crashily destroyed
@@ -383,7 +386,7 @@ void shutdown()
//
// See https://code.ros.org/trac/ros/ticket/3271
//
- log4cxx::Logger::getRootLogger()->getLoggerRepository()->shutdown();
+ log4cxx::Logger::getRootLogger()->getLoggerRepository().lock()->shutdown();
}
} // namespace impl