Added the ability to redirect logging to a callable.
I'm in deep water here, but it seems to work :)
Please come with suggestions, before spent too much time in the wrong way.
Could close #5589
@mvieth do you have any idea to why there is linker errors with pcl::octree:OctreeKey::maxDepth ?
@mvieth do you have any idea to why there is linker errors with pcl::octree:OctreeKey::maxDepth ?
Must have something to do with the usage of maxDepth here: https://github.com/PointCloudLibrary/pcl/blob/master/octree/include/pcl/octree/impl/octree_base.hpp#L98
maxDepth is a static const member, so maybe something related to ODR-use? I have to look at your changes in detail first before I can make a more specific guess.
Ahh, its in that print statement it fails... hmm, still odd though.
Maybe pcl::console::LogRecorder should be a member of the Logger, to avoid creating a stringstream for each stream command - would that make sense?
Nice for me, even if I not like too much the following:
pcl::console::Logger::getInstance().setCallback(...)
because of the getInstance() call... is there a way to remove this indirection level?
Moreover, I think that the previous callback needs to be returned from the setCallaback() call to be able to restore it.
Nice for me, even if I not like too much the following:
pcl::console::Logger::getInstance().setCallback(...)because of the
getInstance()call... is there a way to remove this indirection level?Moreover, I think that the previous callback needs to be returned from the
setCallaback()call to be able to restore it.
Somehow the callback needs to be saved - and having just a static global variable to a std::function, didn't seem right either. At least it was the best solution I found, also browsing other logging frameworks.
Moreover, why generic template "functor" instead of std::function?
Else I couldn't get it to work with lambdas - but maybe I did it wrong 😄
To restore normal logging again, you can just set the callback to a nullptr.
I had a quick look and it looks promising to me, thanks for your work