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

Added logging functionality (spdlog) #190

Merged
merged 1 commit into from
Jul 7, 2021
Merged

Conversation

quantum-shift
Copy link
Collaborator

As discussed in issue #189, spdlog is integrated into prmon. spdlog (version 1.8.5) is added as a submodule. All previous logging statements are replaced with the new logger.

Further, command line switches will be added to handle the logging level of monitors.

Copy link
Collaborator

@amete amete left a comment

Choose a reason for hiding this comment

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

Hi @quantum-shift,

Thanks a lot for the PR! Overall, everything looks fairly nice. I noticed that we still have a few uses of std::cout e.g. this line etc. I think it would be good to unify these as well. I have some more detailed comments below. Please let me know, many thanks.

Best,
Serhan

CMakeLists.txt Outdated
#--- create uninstall target ---------------------------------------------------
include(cmake/prmonUninstall.cmake)

#--- code format targets -------------------------------------------------------
include(cmake/clang-format.cmake)
include(cmake/python-format.cmake)

Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably don't need this empty line.

@@ -1,5 +1,6 @@
find_package(nlohmann_json REQUIRED)


Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably don't need this empty line.

void error(const std::string& message);
};

#endif // PRMON_MESSAGEBASE_H
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing newline at the end of the line.

@@ -10,6 +10,7 @@
#include <iostream>
#include <sstream>

#include "MessageBase.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't really need to include this header in the source files since it's already in the header, no?

@@ -6,17 +6,19 @@

#ifndef PRMON_COUNTMON_H
#define PRMON_COUNTMON_H 1
#define MY_NAME "countmon"
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 we can define this in the source file instead (applies to other cases too) and un-define it after using. Also, we can perhaps call it something more explanatory, e.g. MONITOR_NAME.

Copy link
Member

Choose a reason for hiding this comment

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

If it's going to be private maybe should it be something like THIS_MONITOR_NAME_ (or were you thinking of calling it, e.g., COUNTMON_NAME_ (different in each monitor).

I agree that undefining it at the end is smart - stops it from leaking out.

@@ -103,4 +103,4 @@ const void prmon::fill_units(nlohmann::json& unit_json,
unit_json["Units"]["Avg"][param.get_name()] = param.get_avg_unit();
}
return;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing newline at the end of the line.

@quantum-shift
Copy link
Collaborator Author

Thank you, @amete. It was decided to not change the help output of prmon (that is, not integrate it with the logger). Hence, I have kept the std::cout statements there. Please let me know if there was a change in plan. I have addressed your other comments in a commit.

@quantum-shift quantum-shift requested a review from amete July 6, 2021 16:13
@graeme-a-stewart
Copy link
Member

graeme-a-stewart commented Jul 7, 2021

Thank you, @amete. It was decided to not change the help output of prmon (that is, not integrate it with the logger). Hence, I have kept the std::cout statements there. Please let me know if there was a change in plan. I have addressed your other comments in a commit.

Yes, this also my recollection (it's quite standard behaviour for --help, where one would certainly not want it to go to a logging file!).

@amete
Copy link
Collaborator

amete commented Jul 7, 2021

Thank you, @amete. It was decided to not change the help output of prmon (that is, not integrate it with the logger). Hence, I have kept the std::cout statements there. Please let me know if there was a change in plan. I have addressed your other comments in a commit.

Yes, this also my recollection (it's quite standard behaviour for --help, where one would certainly not want it to go to a logging file!).

That indeed makes sense 👍

Copy link
Member

@graeme-a-stewart graeme-a-stewart left a comment

Choose a reason for hiding this comment

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

Just one utterly trivial point from me! Thanks @quantum-shift

CMakeLists.txt Outdated
set(BUILD_BENCHMARK_LOG OFF)
endif()
set(BUILD_BENCHMARK_LOG "${BUILD_BENCHMARK_LOG}"
CACHE BOOL "Build binary which benchmarks spdlog speed" FORCE)
Copy link
Member

Choose a reason for hiding this comment

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

Very trivial point, but can you change which to that (it's a defining clause)

spdlog was added as a submodule

All previous logging statements replaced with new logger

.github/workflows/ci.yml was updated to initialise submodules recursively
Copy link
Collaborator

@amete amete left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot @quantum-shift!

@amete amete merged commit 9e762bc into HSF:main Jul 7, 2021
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.

3 participants