feat: Add command-line option to control developper information output in diagnostic messages#3980
feat: Add command-line option to control developper information output in diagnostic messages#3980MelReyCG wants to merge 16 commits into
Conversation
| ./bin/geosx --help | ||
|
|
||
| This should print out a brief summary of the available command line arguments: | ||
| This should print out the available command line arguments with their description: |
There was a problem hiding this comment.
| This should print out the available command line arguments with their description: | |
| This should print out the available command line arguments with their descriptions: |
| break; | ||
| case DIAGNOSTIC_INFO_LEVEL: | ||
| { | ||
| DiagnosticInfoLevel infoLevel = DiagnosticInfoLevel( std::stoi( opt.arg ) ); |
There was a problem hiding this comment.
Not sure how these work but do we need to check in case the user gives something like -d -3?
There was a problem hiding this comment.
Just seen how it's implemented. Ignore this comment.
|
|
||
| /** | ||
| * @brief Set the diagnostic messages information level. The higher, the more verbose and | ||
| * developper-oriented the messages will be. |
There was a problem hiding this comment.
| * developper-oriented the messages will be. | |
| * developer-oriented the messages will be. |
| /// 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; |
There was a problem hiding this comment.
(Might not be a suggestion/review but more like a question)
Here m_msgTypeSourceInfoEnabled is correctly initialized in the setDiagnosticInfoLevel( DiagnosticInfoLevel::Basic ) call in the ErrorLogger() constructor.
But if someone modifies the code and for some reason setDiagnosticInfoLevel( ... ) is called too late, or not called at all (through another constructor? or only in an if condition? or something else?) m_msgTypeSourceInfoEnabled will be left uninitialized and produce UB (maybe using garbage booleans producing unexpected results).
Value initialization with empty braces (where bools are set to false by default when value initializing) could prevent UB, and always produce the same result if this theoretical unhappy mentioned earlier path is run.
| stdArray< bool, size_t( MsgType::Count ) > m_msgTypeSourceInfoEnabled; | |
| stdArray< bool, size_t( MsgType::Count ) > m_msgTypeSourceInfoEnabled {}; |
I've still not come across value initialization in GEOS so maybe there is a reason for it?
This PR propose to introduce a new command-line option to control diagnostic log verbosity in GEOS. The goal is to reduce the verbosity of logs by default while still providing detailed developer information when needed.
New option:
For an error,
-d 0would give:... and
-d 1would give:The last option,
-d 2, also enables the output of stack trace and source file for warnings.Stack traces and source files are still included in the YAML output through the
-eoption, but now users can control the presence of developper information in the log through this new-doption.