-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Conversation
if (m_enabled) | ||
{ | ||
Json::Value event; | ||
event["comment"] = "one of the first log events, before any operation is started"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik this isn't implemented in the client and can be removed.
This CLI parameters are okay. Instead of creating a new class for this please look at the existing logging implementation and build on those. Would recommend creating a StructuredLogOutputStream similar to LogOutputStream; remove operator<<, add a log(string&,unsigned) and log(string&,string&), and replace m_sstr with Json::Value m_event. Set fwd declration for Json::Value in Log.h and implement log() in Log.cpp so we don't have to change includes in every file. |
I can understand the thread safety argument, but I really strongly believe that it should stay a separate class as it is right now. I really don't like the idea of making another LogOutputStream. These 2 different kinds of logging systems serve totally different purposes. I will add a mutex to the current class to protect the output as the one in LogOutputStream does. |
dc90863
to
5b28246
Compare
rebased |
The 2 fields missing from the logging for now are:
|
|
||
void starting(std::string const& _clientImpl, const char* _ethVersion) const; | ||
void stopping(std::string const& _clientImpl, const char* _ethVersion) const; | ||
void p2pConnected(std::string const& _id, bi::tcp::endpoint const& _addr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style is incorrect. see latest CodingStandards.txt, 0.a and the golden rule.
f8b4b3c
to
17281c1
Compare
Can anyone try to build this locally? I have no idea why buildbot fails to find json/json.h. It makes no sense. We use it in other files too. |
I've seen this happen before with builds which reference jsoncpp in nonstandard path. I had to explicitly include jsoncpp before /usr/include because it was getting confused with distros that have the standard jsonc library installed, "-I/include/jsoncpp -I/include". You could try changing '#include json/json.h" to "#include jsoncpp/json/json.h". That is if the build machine was recently updated and jsoncpp is now in the path it's usually installed at on most distributions. |
I see. Thanks for the info @onepremise. I'd rather not have to do black magic to appease the buildbot though. Found it out. Seems CMakeLists.txt needed the jsoncpp headers location specified too. In my machine jsoncpp headers were added in /usr/include so no special config was required. The build should be fixed for the PR now. |
f72ae5c
to
e44ab45
Compare
- Also style fixes when problems encountered
- Structured logger is injected as a dependency where needed. - Still a work in progress
LefterisJP, wasn't trying to point this out as a 'black magic' fix. It really is a distribution issue. Most linux distros will have installs which deploy to /usr/include/json and /usr/include/jsoncpp. If you include in your source files, '#include json/json.h', there's no guarantee that others will be able to build your project without encountering this same issue. I know i did when i started building cpp-ethereum. They will have to explicitly know to include jsonccp first in their include path before this succeeds, that is if they have both jsonc and jsoncpp installed. Many open source projects have deferred to referencing jsoncpp in their source files to avoid this issue. Others, using cmake, have updated their FindJsoncpp.cmake file to search for features.h instead of json.h: http://stackoverflow.com/questions/18005880/how-to-writing-a-cmake-module-for-jsoncpp Luckily your buildbot environment isolates the issue. |
This is why we have cmake. The fix was to adjust the cmakefile for libdevcore. All seems to be sorted. I did not want any discrepancies between source files. All of our jsoncpp includes should be |
@@ -103,7 +103,10 @@ class WebThreeDirect : public WebThreeNetworkFace | |||
public: | |||
/// Constructor for private instance. If there is already another process on the machine using @a _dbPath, then this will throw an exception. | |||
/// ethereum() may be safely static_cast()ed to a eth::Client*. | |||
WebThreeDirect(std::string const& _clientVersion, std::string const& _dbPath, bool _forceClean = false, std::set<std::string> const& _interfaces = {"eth", "shh"}, p2p::NetworkPreferences const& _n = p2p::NetworkPreferences(), bytesConstRef _network = bytesConstRef(), int miners = -1); | |||
WebThreeDirect(std::string const& _clientVersion, std::string const& _dbPath, bool _forceClean = false, | |||
std::set<std::string> const& _interfaces = {"eth", "shh"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style (one indent only)
style fixes needed. simple rule: if an expression goes on multiple lines, it's always:
note, this is not:
nor
|
@@ -103,7 +103,14 @@ class WebThreeDirect : public WebThreeNetworkFace | |||
public: | |||
/// Constructor for private instance. If there is already another process on the machine using @a _dbPath, then this will throw an exception. | |||
/// ethereum() may be safely static_cast()ed to a eth::Client*. | |||
WebThreeDirect(std::string const& _clientVersion, std::string const& _dbPath, bool _forceClean = false, std::set<std::string> const& _interfaces = {"eth", "shh"}, p2p::NetworkPreferences const& _n = p2p::NetworkPreferences(), bytesConstRef _network = bytesConstRef(), int miners = -1); | |||
WebThreeDirect( | |||
std::string const& _clientVersion, std::string const& _dbPath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two items on one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arrggh sorry
a2cb12d
to
5f191f4
Compare
} | ||
} | ||
|
||
void StructuredLogger::chainReceivedNewBlock(string const& _hash, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still wrong.
Eth c++ client structured logging
Implementing the Structured Logging Spec for the C++ client.
./eth/eth --structured-logging
will enable structured logging.A nice bonus is that with the
--structured-logging-format <%Y-%m-%d>
we can give a strftime() type of format string to influence the way timestamps are printed.Stop
log event when the client shuts down. I think it would be needed.