Skip to content

Commit

Permalink
Merge pull request #343 from ros/rosconsole_log4cxx_logger_name_segfault
Browse files Browse the repository at this point in the history
fix rosconsole segfault when using ROSCONSOLE_FORMAT with  (fix #342)
  • Loading branch information
dirk-thomas committed Jan 24, 2014
2 parents fedf4fb + 37197be commit 9e8b935
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ROSConsoleStdioAppender : public log4cxx::AppenderSkeleton
std::string msg = event->getMessage();
#endif
const log4cxx::spi::LocationInfo& location_info = event->getLocationInformation();
::ros::console::backend::print(this, level, msg.c_str(), location_info.getFileName(), location_info.getMethodName().c_str(), location_info.getLineNumber());
::ros::console::backend::print(event.operator->(), level, msg.c_str(), location_info.getFileName(), location_info.getMethodName().c_str(), location_info.getLineNumber());
}

virtual void close()
Expand Down Expand Up @@ -205,12 +205,12 @@ void* getHandle(const std::string& name)

std::string getName(void* handle)
{
log4cxx::Logger* logger = (log4cxx::Logger*)handle;
const log4cxx::spi::LoggingEvent* event = (const log4cxx::spi::LoggingEvent*)handle;
#ifdef _MSC_VER
LOG4CXX_ENCODE_CHAR(tmpstr, event->getName()); // has to handle LogString with wchar types.
LOG4CXX_ENCODE_CHAR(tmpstr, event->getLoggerName()); // has to handle LogString with wchar types.
return tmpstr // tmpstr gets instantiated inside the LOG4CXX_ENCODE_CHAR macro
#else
return logger->getName();
return event->getLoggerName();
#endif
}

Expand Down

0 comments on commit 9e8b935

Please sign in to comment.