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

Start using spdlog in the repo #225

Merged
merged 8 commits into from
Mar 9, 2021
Merged

Start using spdlog in the repo #225

merged 8 commits into from
Mar 9, 2021

Conversation

GiulioRomualdi
Copy link
Member

@GiulioRomualdi GiulioRomualdi commented Mar 3, 2021

This pr should be seen as a point where we can discuss. Then if we found a common agreement we may think to merge it.

In this PR I added spdlog. It is a nice log that can be used to print stuff in the terminal.
The dependency can be installed with apt vcpkg and brew.

This is the output of the TimeVaryingDCMTest with the code implemented in this PR.
image

We can further customize the output: https://github.com/gabime/spdlog/wiki/3.-Custom-formatting.

It's also possible to automatically print the name of the function, name of the file and line. However, we should define some macros.
The nice thing is that it can be used in a multithread application https://cran.r-project.org/web/packages/RcppSpdlog/vignettes/introduction.html

cc @traversaro @prashanthr05 @S-Dafarra


TextLogging::Logger* const log()
{
auto logger = spdlog::get("console");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know if it make sense to use a blf-specific name for this, especially given that we modify it (set level, set pattern) so it it may be better to avoid conflicts with other libraries that already may use spdlog "console"?

Comment on lines +5 to +9
add_bipedal_locomotion_library(
NAME TextLogging
PUBLIC_HEADERS include/BipedalLocomotion/TextLogging/Logger.h
SOURCES src/Logger.cpp
PUBLIC_LINK_LIBRARIES spdlog::spdlog)
Copy link
Collaborator

@prashanthr05 prashanthr05 Mar 4, 2021

Choose a reason for hiding this comment

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

Nitpick: Why the names Textlogging and a Logger? I believe if we are going to use this only for debug prints then Logger is too generic for a name, maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm terrible with the names 😃 . Do you have any suggestions?

Copy link
Collaborator

@prashanthr05 prashanthr05 Mar 4, 2021

Choose a reason for hiding this comment

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

Now that, I've seen these names, I am not able to think of others quickly ;D

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's ok.

@GiulioRomualdi GiulioRomualdi marked this pull request as ready for review March 4, 2021 10:29
@GiulioRomualdi GiulioRomualdi self-assigned this Mar 4, 2021
@GiulioRomualdi
Copy link
Member Author

GiulioRomualdi commented Mar 4, 2021

Windows is failing with

  By not providing "Findspdlog.cmake" in CMAKE_MODULE_PATH this project has
See also "D:/a/bipedal-locomotion-framework/bipedal-locomotion-framework/build/CMakeFiles/CMakeOutput.log".
  asked CMake to find a package configuration file provided by "spdlog", but
  CMake did not find one.

  Could not find a package configuration file provided by "spdlog" with any
  of the following names:

    spdlogConfig.cmake
    spdlog-config.cmake

  Add the installation prefix of "spdlog" to CMAKE_PREFIX_PATH or set
  "spdlog_DIR" to a directory containing one of the above files.  If "spdlog"
  provides a separate development package or SDK, be sure it has been
  installed.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@traversaro
Copy link
Collaborator

Can you update the superbuild to document and install in CI spdlog? Even in the usual base dependencies is fine. Otherwise I can do it myself.

@GiulioRomualdi
Copy link
Member Author

Can you update the superbuild to document and install in CI spdlog? Even in the usual base dependencies is fine. Otherwise I can do it myself.

sure

@GiulioRomualdi
Copy link
Member Author

Let me know if we can merge it or we should update the superbuild before

@traversaro
Copy link
Collaborator

traversaro commented Mar 4, 2021

Let me know if we can merge it or we should update the superbuild before

If we can update the superbuild before it would avoid a bit of red sadness in superbuild CI. : )
The 0.6.2 vcpkg binaries are being prepared in https://github.com/robotology/robotology-superbuild-dependencies-vcpkg/actions/runs/621356334, once that is done I think we can update the superbuild.

@traversaro
Copy link
Collaborator

Let me know if we can merge it or we should update the superbuild before

If we can update the superbuild before it would avoid a bit of red sadness in superbuild CI. : )
The 0.6.2 vcpkg binaries are being prepared in https://github.com/robotology/robotology-superbuild-dependencies-vcpkg/actions/runs/621356334, once that is done I think we can update the superbuild.

0.6.2 released with spdlog: https://github.com/robotology/robotology-superbuild-dependencies-vcpkg/releases/tag/v0.6.2 .

@traversaro
Copy link
Collaborator

Furthermore, given that we use master as Stable branch of bipedal-locomotion-control, we need to make sure that people that use ROBOTOLOGY_USES_DYNAMICS have libspdlog-dev installed, probably an announcement in internal chat is enough.

@GiulioRomualdi
Copy link
Member Author

PR opened robotology/robotology-superbuild#645

@GiulioRomualdi GiulioRomualdi force-pushed the spdlogger branch 2 times, most recently from 598c79a to a3038a0 Compare March 5, 2021 11:47
@GiulioRomualdi
Copy link
Member Author

same error in windows-debug

2021-03-05T12:26:53.2753752Z CMake Error at C:/robotology/vcpkg/scripts/buildsystems/vcpkg.cmake:644 (_find_package):
2021-03-05T12:26:53.2755113Z   By not providing "Findspdlog.cmake" in CMAKE_MODULE_PATH this project has
2021-03-05T12:26:53.2755928Z -- Configuring incomplete, errors occurred!
2021-03-05T12:26:53.2757307Z See also "D:/a/bipedal-locomotion-framework/bipedal-locomotion-framework/build/CMakeFiles/CMakeOutput.log".
2021-03-05T12:26:53.2758666Z   asked CMake to find a package configuration file provided by "spdlog", but
2021-03-05T12:26:53.2759436Z   CMake did not find one.
2021-03-05T12:26:53.2759827Z 
2021-03-05T12:26:53.2760463Z   Could not find a package configuration file provided by "spdlog" with any
2021-03-05T12:26:53.2761182Z   of the following names:
2021-03-05T12:26:53.2761561Z 
2021-03-05T12:26:53.2762069Z     spdlogConfig.cmake
2021-03-05T12:26:53.2762678Z     spdlog-config.cmake
2021-03-05T12:26:53.2763108Z 
2021-03-05T12:26:53.2763734Z   Add the installation prefix of "spdlog" to CMAKE_PREFIX_PATH or set
2021-03-05T12:26:53.2764586Z   "spdlog_DIR" to a directory containing one of the above files.  If "spdlog"
2021-03-05T12:26:53.2765786Z   provides a separate development package or SDK, be sure it has been
2021-03-05T12:26:53.2766343Z   installed.
2021-03-05T12:26:53.2768198Z Call Stack (most recent call first):
2021-03-05T12:26:53.2769330Z   cmake/BipedalLocomotionFrameworkDependencies.cmake:15 (find_package)
2021-03-05T12:26:53.2770324Z   CMakeLists.txt:21 (include)

but now spdlog is installed within robotology-superbuild-dependencies-vcpkg

@traversaro
Copy link
Collaborator

Sorry, the problem is described and fixed in robotology/robotology-superbuild-dependencies-vcpkg#43 .

@GiulioRomualdi
Copy link
Member Author

Waiting the approval before merging

@GiulioRomualdi
Copy link
Member Author

GiulioRomualdi commented Mar 8, 2021

Friendly Ping @S-Dafarra and @prashanthr05 :)

Copy link
Member

@S-Dafarra S-Dafarra left a comment

Choose a reason for hiding this comment

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

It looks good to me

@GiulioRomualdi GiulioRomualdi merged commit 7f02bcd into master Mar 9, 2021
@GiulioRomualdi GiulioRomualdi deleted the spdlogger branch March 9, 2021 08:45
@S-Dafarra
Copy link
Member

Not a big deal, but for @traversaro there were still requested changes. I guess they were resolved right?

@traversaro
Copy link
Collaborator

Not a big deal, but for @traversaro there were still requested changes. I guess they were resolved right?

Yes!

@prashanthr05
Copy link
Collaborator

Waiting the approval before merging

Sorry, I had not noticed this. I had taken a look but forgot to approve.

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

Successfully merging this pull request may close these issues.

4 participants