-
Notifications
You must be signed in to change notification settings - Fork 101
feat: Add command-line option to control developper information output in diagnostic messages #3980
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
base: develop
Are you sure you want to change the base?
Changes from all commits
b7034da
ea26cee
5380a1d
9e5c55d
ad94434
7507c27
5ac4c41
09a2daa
4d6ff06
3f6837b
ab63cbc
630f611
2c774f3
af599a5
86c7722
86e4e06
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |||||
| #include "common/DataTypes.hpp" | ||||||
| #include "common/format/Format.hpp" | ||||||
| #include "common/format/StringUtilities.hpp" | ||||||
|
|
||||||
| #include <mutex> | ||||||
|
|
||||||
| namespace geos | ||||||
|
|
@@ -111,13 +112,28 @@ struct ErrorContext | |||||
| * @enum MsgType | ||||||
| * Enum listing the different types of possible diagnostics | ||||||
| */ | ||||||
| enum class MsgType | ||||||
| enum class MsgType : integer | ||||||
| { | ||||||
| Undefined, | ||||||
| Error, | ||||||
| ExternalError, | ||||||
| Warning, | ||||||
| Exception, | ||||||
| Undefined | ||||||
| Count // internal use, keep at last | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
| * @enum DiagnosticInfoLevel | ||||||
| * Enum listing the different types of possible diagnostic information levels | ||||||
| */ | ||||||
| enum class DiagnosticInfoLevel : integer | ||||||
| { | ||||||
| /// basic information (default) | ||||||
| Basic = 0, | ||||||
| /// errors source-code information | ||||||
| ErrorSources= 1, | ||||||
| /// warnings & errors source-code information | ||||||
| WarningSources = 2, | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -295,6 +311,8 @@ class ErrorLogger | |||||
| */ | ||||||
| GEOS_HOST static ErrorLogger & global(); | ||||||
|
|
||||||
| ErrorLogger(); | ||||||
|
|
||||||
| /** | ||||||
| * @brief Create the YAML file or overwrite the contents if a YAML file of the same name already exists | ||||||
| * And write its header when the command line option is enabled | ||||||
|
|
@@ -322,6 +340,14 @@ class ErrorLogger | |||||
| void setOutputFilename( std::string_view filename ) | ||||||
| { m_filename = filename; } | ||||||
|
|
||||||
| /** | ||||||
| * @brief Set the diagnostic messages information level. The higher, the more verbose and | ||||||
| * developper-oriented the messages will be. | ||||||
|
Contributor
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
|
||||||
| * @param level the desired information level. If level is not an DiagnosticInfoLevel enum label, | ||||||
| * the behaviour of DiagnosticInfoLevel::Basic. | ||||||
| */ | ||||||
| void setDiagnosticInfoLevel( DiagnosticInfoLevel level ); | ||||||
|
|
||||||
| /** | ||||||
| * @return The file name of the output error file | ||||||
| */ | ||||||
|
|
@@ -333,7 +359,13 @@ class ErrorLogger | |||||
| * @param type the message type label | ||||||
| * @return the string representation of the message type | ||||||
| */ | ||||||
| static std::string toString( MsgType type ); | ||||||
| static std::string typeToString( MsgType type ); | ||||||
|
|
||||||
| /** | ||||||
| * @param type the message type label | ||||||
| * @return true if the message type source information output is enabled | ||||||
| */ | ||||||
| bool isSourceInfoEnabled( MsgType type ) const; | ||||||
|
|
||||||
| /** | ||||||
| * @return Return the const general log stream | ||||||
|
|
@@ -384,8 +416,11 @@ class ErrorLogger | |||||
| * @brief Format all information in ErrorMsg and write it to the specified output stream | ||||||
| * @param errMsg The struct containing the error/warning object | ||||||
| * @param os The output stream | ||||||
| * @param enableSourceInfo if true, information on source code is included in the message | ||||||
| */ | ||||||
| static void formatMsgForLog( DiagnosticMsg const & errMsg, std::ostream & os ); | ||||||
| static void formatMsgForLog( DiagnosticMsg const & errMsg, | ||||||
| std::ostream & os, | ||||||
| bool enableSourceInfo ); | ||||||
|
|
||||||
| /** | ||||||
| * @brief Write the ErrorMsg into the log stream output stream | ||||||
|
|
@@ -407,6 +442,8 @@ class ErrorLogger | |||||
| std::mutex m_errorHandlerAsciiMutex; | ||||||
| /// Avoid concurrent access between threads for yaml outputs | ||||||
| std::mutex m_errorHandlerYamlMutex; | ||||||
| /// Indicated if the source file information output is enabled for a given message type | ||||||
| stdArray< bool, size_t( MsgType::Count ) > m_msgTypeSourceInfoEnabled; | ||||||
|
Contributor
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. (Might not be a suggestion/review but more like a question) Value initialization with empty braces (where
Suggested change
I've still not come across value initialization in GEOS so maybe there is a reason for it? |
||||||
|
|
||||||
| /** | ||||||
| * @brief Write all the information retrieved about the error/warning message into the YAML stream | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| */ | ||
|
|
||
| #include "initialization.hpp" | ||
| #include "common/logger/ErrorHandling.hpp" | ||
| #include "version.hpp" | ||
|
|
||
| #include "common/DataTypes.hpp" | ||
|
|
@@ -97,6 +98,7 @@ std::unique_ptr< CommandLineOptions > parseCommandLineOptions( int argc, char * | |
| ZPAR, | ||
| SCHEMA, | ||
| VALIDATE_INPUT, | ||
| DIAGNOSTIC_INFO_LEVEL, | ||
| NONBLOCKING_MPI, | ||
| SUPPRESS_PINNED, | ||
| PROBLEMNAME, | ||
|
|
@@ -121,6 +123,10 @@ std::unique_ptr< CommandLineOptions > parseCommandLineOptions( int argc, char * | |
| { ZPAR, 0, "z", "zpartitions", Arg::numeric, "\t-z, --z-partitions, \t Number of partitions in the z-direction" }, | ||
| { SCHEMA, 0, "s", "schema", Arg::nonEmpty, "\t-s, --schema, \t Name of the output schema" }, | ||
| { VALIDATE_INPUT, 0, "v", "validate-input", Arg::None, "\t-v, --validate-input, \t Only do the loading phase, and not actual simulation. Useful to validate 'input'." }, | ||
| { DIAGNOSTIC_INFO_LEVEL, 0, "d", "diagnostic-info-level", Arg::numeric, "\t-d, --diagnostic-info-level, \t Diagnostic message information level:\n" | ||
| "\t \t 0 = basic information (default),\n" | ||
| "\t \t 1 = errors source-code information,\n" | ||
| "\t \t 2 = warnings & errors source-code information." }, | ||
| { NONBLOCKING_MPI, 0, "b", "use-nonblocking", Arg::None, "\t-b, --use-nonblocking, \t Use non-blocking MPI communication" }, | ||
| { PROBLEMNAME, 0, "n", "name", Arg::nonEmpty, "\t-n, --name, \t Name of the problem, used for output" }, | ||
| { SUPPRESS_PINNED, 0, "s", "suppress-pinned", Arg::None, "\t-s, --suppress-pinned, \t Suppress usage of pinned memory for MPI communication buffers" }, | ||
|
|
@@ -222,6 +228,12 @@ std::unique_ptr< CommandLineOptions > parseCommandLineOptions( int argc, char * | |
| commandLineOptions->onlyValidateInput = true; | ||
| } | ||
| break; | ||
| case DIAGNOSTIC_INFO_LEVEL: | ||
| { | ||
| DiagnosticInfoLevel infoLevel = DiagnosticInfoLevel( std::stoi( opt.arg ) ); | ||
|
Contributor
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. Not sure how these work but do we need to check in case the user gives something like
Contributor
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. Just seen how it's implemented. Ignore this comment. |
||
| ErrorLogger::global().setDiagnosticInfoLevel( infoLevel ); | ||
| } | ||
| break; | ||
| case PROBLEMNAME: | ||
| { | ||
| commandLineOptions->problemName = opt.arg; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.