-
Notifications
You must be signed in to change notification settings - Fork 65
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
Adding console output methods to some classes #872
Changes from 5 commits
6a86654
32cc94f
824e71d
335b710
6086785
490b3bb
d390bf2
bad74da
52e64a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -466,6 +466,56 @@ class DagMC { | |||||
return MBI_shared_ptr; | ||||||
} | ||||||
|
||||||
// Verbosity levels | ||||||
// -1 : "override" the current verbosity setting and write message | ||||||
// 0 : No output | ||||||
// 1 : All output | ||||||
int set_verbosity(int val) { | ||||||
int verbosity_max = 0; | ||||||
int verbosity_min = 1; | ||||||
if (val < verbosity_min || val > verbosity_max) | ||||||
warning("Invalid verbosity value " + std::to_string(val) + | ||||||
" will be set to nearest valid value."); | ||||||
val = std::min(std::max(verbosity_min, val), verbosity_max); | ||||||
return verbosity = val; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless my brain is missing something, this will always result in 0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mm yeah mentally bit-flipped the initializer values at the beginning of this function. |
||||||
} | ||||||
|
||||||
int get_verbosity(int val) { return verbosity; } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this take an argument- seems confusing |
||||||
|
||||||
/** console output mechanism | ||||||
* @param msg Message to be written to the console | ||||||
* @param lvl Message will not be written if the verbosity level | ||||||
* is higher than the class instance's current verbosity setting. | ||||||
* Use of -1 ensures the message will always be written. | ||||||
* @param newline Whether or not to apend a newline to the message. | ||||||
*/ | ||||||
void message(const std::string& msg, int lvl = 1, bool newline = true) const { | ||||||
// do not write message if level is higher than | ||||||
// verbosity setting | ||||||
if (lvl > verbosity) return; | ||||||
// otherwise, display message | ||||||
if (newline) | ||||||
std::cout << msg << "\n"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's preferred to use a newline literal these days. Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could do it all in one go in a separate changeset though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it was preferred because it is platform independent (e.g. Windows carriage returns...). That's the only reason I suggested it. |
||||||
else | ||||||
std::cout << msg; | ||||||
} | ||||||
|
||||||
/** write a warning message to the console | ||||||
* @param msg Message to be written to the console | ||||||
* @param newline Whether or not to apend a newline to the message. | ||||||
*/ | ||||||
void warning(const std::string& msg, bool newline = true) const { | ||||||
message("WARNING: " + msg, -1, newline); | ||||||
} | ||||||
|
||||||
/** write an error message to the console | ||||||
* @param msg Message to be written to the console | ||||||
* @param newline Whether or not to apend a newline to the message. | ||||||
*/ | ||||||
void err_msg(const std::string& msg, bool newline = true) const { | ||||||
message("ERROR: " + msg, -1, newline); | ||||||
} | ||||||
|
||||||
private: | ||||||
/* PRIVATE MEMBER DATA */ | ||||||
|
||||||
|
@@ -486,6 +536,9 @@ class DagMC { | |||||
|
||||||
std::unique_ptr<RayTracer> ray_tracer; | ||||||
|
||||||
/** verbosity setting for DAGMC operations */ | ||||||
int verbosity{1}; | ||||||
|
||||||
public: | ||||||
Tag nameTag, facetingTolTag; | ||||||
|
||||||
|
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 this may fix the linux build test failure
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, but I think this PR has been replaced by another ( #876 ), so will be close by @pshriwise soon.
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.
Correct! Closing now.