-
Notifications
You must be signed in to change notification settings - Fork 11
Guard most logging with the verbose logging option #36
Conversation
bmoyles0117
left a comment
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.
I would generally vote for log levels instead of having conditionals based on the flag everywhere. I think this is a good interim solution for reducing log spam, but the complexity could be greatly reduced with log levels.
| // frequent, and could be promoted to ERROR. | ||
| LOG(WARNING) << "No matching resource for " << id; | ||
| if (agent_.config_.VerboseLogging()) { | ||
| LOG(WARNING) << "No matching resource for " << id; |
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.
I would consider logging this at least once per resource instead of guarding by verbose logging, as I would agree repetitively spamming an undiscovered resource would be spammy, even though this would happen within the 60 second poll interval for newly created docker containers.
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.
Logging this once isn't something that's easy to do with the current logging framework.
Besides, this is a handler for the incoming requests, so it would log every time an agent wants to translate a resource, which is a lot more frequent than once a minute.
src/configuration.cc
Outdated
| boost::program_options::options_description flags_desc; | ||
| flags_desc.add_options() | ||
| ("help", "Print help message") | ||
| ("verbose", boost::program_options::value<bool>(&verbose_logging_), |
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.
Will this support shorthand for the first letter as well? It would be nice to have -v as well as --verbose.
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.
Done.
src/environment.cc
Outdated
| }; | ||
|
|
||
| json::value ReadCredentials(const std::string& credentials_file) | ||
| json::value ReadCredentials(const std::string& credentials_file, bool verbose) |
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.
s/verbose/verbose_logging/g for consistency.
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.
Done.
igorpeshansky
left a comment
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.
Thanks. PTAL.
src/configuration.cc
Outdated
| boost::program_options::options_description flags_desc; | ||
| flags_desc.add_options() | ||
| ("help", "Print help message") | ||
| ("verbose", boost::program_options::value<bool>(&verbose_logging_), |
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.
Done.
src/environment.cc
Outdated
| }; | ||
|
|
||
| json::value ReadCredentials(const std::string& credentials_file) | ||
| json::value ReadCredentials(const std::string& credentials_file, bool verbose) |
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.
Done.
| // frequent, and could be promoted to ERROR. | ||
| LOG(WARNING) << "No matching resource for " << id; | ||
| if (agent_.config_.VerboseLogging()) { | ||
| LOG(WARNING) << "No matching resource for " << id; |
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.
Logging this once isn't something that's easy to do with the current logging framework.
Besides, this is a handler for the incoming requests, so it would log every time an agent wants to translate a resource, which is a lot more frequent than once a minute.
| .options(all_desc).positional(positional_desc).run(), flags); | ||
| boost::program_options::notify(flags); | ||
|
|
||
| if (flags.count("help")) { |
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.
Will this work if -h is passed in instead of --help?
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.
Yes, it will.
bmoyles0117
left a comment
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.
LGTM
| ("verbose", boost::program_options::value<bool>(&verbose_logging_), | ||
| "Enable verbose logging") | ||
| ; | ||
| boost::program_options::options_description hidden_desc; |
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.
Could you explain why this is hidden as opposed to just setup to have a default value?
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.
I didn't want it to show up in the --help output. Maybe that was overkill. I went back and forth on that (and also tried an approach where the config file could only be specified as a positional parameter, but quickly reverted that). But it's harmless to leave it as-is for now.
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.
Sounds good to me just wanted the rationale behind it. Thanks.
| // As we add more resource mappings, these will become less and less | ||
| // frequent, and could be promoted to ERROR. | ||
| LOG(WARNING) << "No matching resource for " << id; | ||
| if (agent_.config_.VerboseLogging()) { |
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.
Is this the only way to do it? Seems like if conditionals to guard logging defeats the purpose of using log levels like INFO and DEBUG. Also elsewhere.
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.
Right, the two are orthogonal. With verbose logging, we can get messages at all 4 levels (ERROR, WARNING, INFO, DEBUG). You're right that ideally this would be built into the logging framework itself, but that's a much larger undertaking.
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.
I think we all agree here, I had spoken with @igorpeshansky offline and we came to the conclusion that the goal for now is to reduce log spam with a simple flag and implement full support for log levels later on down the road.
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.
I see. Alright. Deferring for now.
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.
LGTM 👌
| ("verbose", boost::program_options::value<bool>(&verbose_logging_), | ||
| "Enable verbose logging") | ||
| ; | ||
| boost::program_options::options_description hidden_desc; |
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.
Sounds good to me just wanted the rationale behind it. Thanks.
dhrupadb
left a comment
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.
LGTM 👌
Adds command-line flag support as well.