-
Notifications
You must be signed in to change notification settings - Fork 29
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 logging tool in HDE library #248
Comments
I was having a look to what contained in If we agree on that, one point to understand is if it is better to use same name for the tool (so it is familiar moving around the libraries), or to pick something different from Another consideration might be to adding Any opinion on this @GiulioRomualdi @S-Dafarra @diegoferigo @Yeshasvitvs @prashanthr05 @traversaro ? |
This sounds good to me. |
Ok for copying the logger code for me. In this particular case it also make sense as we want to enable debug prints when hde is compiled in debug (see https://github.com/dic-iit/bipedal-locomotion-framework/blob/master/src/TextLogging/src/Logger.cpp#L29), without a strict dependency on how blf is compiled. |
If you do not want to use spdlog (even if it can be easily installed) you can use this approach https://github.com/GiulioRomualdi/scs-eigen/blob/main/src/ScsEigen/include/ScsEigen/Logger.h
I agree on this. Furthermore, notice that the logger in blf is a singleton. So if you call |
Here is how spdlog is used in drake https://github.com/RobotLocomotion/drake/blob/026804c4e89c504f657a804764de598739426d60/common/text_logging.cc#L1 |
Just a nit that supports my personal fight against the usage of raw pointers. The typical Singleton pattern could use: // Instead of:
// Logger* const ScsEigen::log()
const Logger& ScsEigen::log()
{
static Logger l;
return l;
} Maybe the same would be valid in the spdlog case that uses a shared pointer. |
Hi @diegoferigo when I implemented the logger in blf I didn't think about it and now I'm too lazy to change all the code 😄 A possible implementation is const Logger& ScsEigen::log()
{
// Since the oobject is static the memory is not deallocated
static std::shared_ptr<TextLogging::Logger>logger(loggerCreation());
// the logger exist because loggerCreation is called.
return *logger;
} notice that |
Yep! My comment was really a nit in case people copy-and-past the linked code. Regarding the blf implementation, I was referring to this code. A global object is always valid, and something tickles every time I see |
At this stage, the hde library depends on YARP just for the terminal logging tool. We could then remove this dependency by moving to an independent tool (e.g.
spdlog
as in ami-iit/bipedal-locomotion-framework#225)The text was updated successfully, but these errors were encountered: