summarylogtreecommitdiffstats
path: root/log4cxx0.13.patch
blob: ba7968099d6f9c4338aebac7c77a2df30c7389de (plain)
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
92
93
94
From 338da6f966ef35454672730702203c54dddea027 Mon Sep 17 00:00:00 2001
From: readlnh <readlnh@163.com>
Date: Tue, 18 Oct 2022 19:24:36 +0200
Subject: [PATCH] fix build with log4cxx 0.13

---
 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..ce122b1f 100644
--- a/src/rosconsole/impl/rosconsole_log4cxx.cpp
+++ b/src/rosconsole/impl/rosconsole_log4cxx.cpp
@@ -127,6 +127,8 @@ protected:
   }
 };
 
+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);
@@ -184,7 +186,7 @@ void print(void* handle, ::ros::console::Level level, const char* str, const cha
   log4cxx::Logger* logger  = (log4cxx::Logger*)handle;
   try
   {
-    logger->forcedLog(g_level_lookup[level], str, log4cxx::spi::LocationInfo(file, function, line));
+    logger->forcedLog(g_level_lookup[level], str, log4cxx::spi::LocationInfo(file, log4cxx::spi::LocationInfo::calcShortFileName(file), function, line));
   }
   catch (std::exception& e)
   {
@@ -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::LoggerRepository *repo = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME)->getLoggerRepository() ;
 
   log4cxx::LoggerList current_loggers = repo->getCurrentLoggers();
   log4cxx::LoggerList::iterator it = current_loggers.begin();
@@ -352,20 +354,21 @@ protected:
   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
-- 
2.38.0