Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deregistry function for LogAppender. #17

Merged
merged 7 commits into from
Sep 11, 2018
Merged

Add deregistry function for LogAppender. #17

merged 7 commits into from
Sep 11, 2018

Conversation

tahsinkose
Copy link
Contributor

Resolution of memory leak issue in ROSOutAppender requires deregistration of g_rosout_appender. This PR implements that functionality.

@dirk-thomas dirk-thomas added the enhancement New feature or request label Sep 11, 2018
@dirk-thomas
Copy link
Member

The same function needs to be added to the other backends.

Add deregistry to other backends as well.
@tahsinkose
Copy link
Contributor Author

I don't know why build fails, Jenkins shows nothing about the failure. I thought it was because of multiple commits, so squashed them but didn't work either.

@dirk-thomas
Copy link
Member

The Jenkins build output contains:

[ 50%] Building CXX object CMakeFiles/rosconsole_log4cxx.dir/src/rosconsole/impl/rosconsole_log4cxx.cpp.o
/tmp/catkin_workspace/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function ‘void ros::console::impl::deregister_appender()’:
/tmp/catkin_workspace/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:358:3: error: ‘logger’ was not declared in this scope
   logger->removeAppender(g_log4cxx_appender);
   ^~~~~~
/tmp/catkin_workspace/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:358:3: note: suggested alternative: ‘log1pq’
   logger->removeAppender(g_log4cxx_appender);
   ^~~~~~
   log1pq

@tahsinkose
Copy link
Contributor Author

Thanks for your patient guidance :)

src/rosconsole/rosconsole.cpp Outdated Show resolved Hide resolved
@@ -97,6 +97,10 @@ void register_appender(LogAppender* appender)
rosconsole_glog_appender = appender;
}

void deregister_appender(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the same style of the file: putting the { in a new line.

Same below.

const log4cxx::LoggerPtr& logger = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME);
logger->removeAppender(g_log4cxx_appender);
delete g_log4cxx_appender;
g_log4cxx_appender = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the same style of the file: 2 space indentation (no tabs).

Same below.

@@ -97,6 +97,10 @@ void register_appender(LogAppender* appender)
rosconsole_glog_appender = appender;
}

void deregister_appender(){
rosconsole_glog_appender = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use 0 here for consistency - that is the default value further up in the same file and in the other implementations.

@dirk-thomas
Copy link
Member

Thank you for adding this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants