|
| | GLogger (const std::shared_ptr< GOptions > &gopts, const std::string &cname, const std::string &lname="") |
| | Constructs a GLogger instance and resolves its runtime configuration.
|
| | GLogger () |
| | Default constructor.
|
| | ~GLogger () |
| | Destructor.
|
| template<typename... Args> |
| void | debug (debug_type type, std::string_view message, Args &&... args) const |
| | Logs a debug message if the debug level is nonzero.
|
| template<typename... Args> |
| void | info (int level, std::string_view message, Args &&... args) const |
| | Logs a complete message template, optionally gated by verbosity level.
|
template<typename Message, typename... Args>
requires std::is_convertible_v<Message, std::string_view> |
| void | info (Message &&message, Args &&... args) const |
| | Convenience overload of info() that defaults to level 0.
|
| template<typename... Args> |
| void | warning (std::string_view message, Args &&... args) const |
| | Logs a warning message.
|
| template<typename... Args> |
| void | error (int exit_code, std::string_view message, Args &&... args) const |
| | Logs an error message and terminates the process.
|
| template<typename... Args> |
| void | critical (std::string_view message, Args &&... args) const |
| | Logs a critical message.
|
| template<typename... Args> |
| void | infoTemplate (int level, std::string_view message, Args &&... args) const |
| | Transitional alias for info(), with identical template and filtering semantics.
|
template<typename Message, typename... Args>
requires std::is_convertible_v<Message, std::string_view> |
| void | infoTemplate (Message &&message, Args &&... args) const |
| | Logs a message template at info level 0; see infoTemplate(int, std::string_view, Args&&...).
|
| template<typename... Args> |
| void | debugTemplate (debug_type type, std::string_view message, Args &&... args) const |
| | Transitional alias for debug().
|
| template<typename... Args> |
| void | warningTemplate (std::string_view message, Args &&... args) const |
| | Transitional alias for warning().
|
| template<typename... Args> |
| void | errorTemplate (int exit_code, std::string_view message, Args &&... args) const |
| | Transitional alias for error().
|
| template<typename... Args> |
| void | criticalTemplate (std::string_view message, Args &&... args) const |
| | Transitional alias for critical().
|
| std::string | get_class_name () const |
| | Returns the caller-provided class name associated with this logger instance.
|
| const std::string & | get_language () const |
| | Normalized language selected from options, environment, or system settings.
|
GLogger centralizes formatted output for simulation components. Messages are emitted to the Geant4 streams (G4cout/G4cerr) and can be filtered based on configuration obtained from GOptions.
Key responsibilities:
- Apply verbosity/debug filtering consistently across the codebase.
- Render standardized message headers including a per-instance atomic counter.
- Accept complete message templates with numbered, streamable parameters.
- Resolve cached translations automatically, retaining English for missing messages.
- Keep the transitional *Template() methods as forwarding aliases.
- Filtering model
- Debug messages are emitted only when the resolved debug level is nonzero.
- Info messages can be emitted at level 0, 1, or 2, each gated by the resolved verbosity level.
- Warning and critical messages are always emitted.
- Error messages are emitted and then the process terminates with an exit code.
- Warning
- This class writes to shared output streams. While the internal counter is thread-safe, output interleaving is still possible depending on the underlying stream behavior.
Definition at line 91 of file glogger.h.
template<typename... Args>
| void GLogger::info |
( |
int | level, |
|
|
std::string_view | message, |
|
|
Args &&... | args ) const |
|
inline |
Info messages support three levels of detail:
- level 0 : Always printed (baseline information).
- level 1 : Printed only when
verbosity_level > 0.
- level 2 : Printed only when
verbosity_level > 1 (most detailed).
Placeholders %1 through %99 identify arguments by their one-based position. They may be reordered or repeated; each supplied argument must appear at least once. %% emits a literal percent sign. Other percent signs are literal. Inserted values are never parsed as templates. Each argument is converted once using its own std::ostringstream and normal stream formatting. All logging categories share these placeholder rules. Catalog lookup precedes parameter substitution; untranslated messages retain their English templates. Language selection never changes numeric formatting.
Filtering happens before formatting; C++ still evaluates argument expressions before the call. Dynamic or already-formatted text should be logged as a value: info("%1", text).
- Template Parameters
-
| Args | Parameter types with stream insertion support (at most 99 arguments). |
- Parameters
-
| level | The info importance/detail level (0, 1, or 2). |
| message | Complete message template. |
| args | Values referenced by the numbered placeholders. |
- Exceptions
-
| std::invalid_argument | If an emitted template references an unavailable/invalid argument or leaves a supplied argument unused. A suppressed message is not validated or formatted. |
| (process | termination) If level is not 0, 1, or 2, this method prints a fatal error and terminates the process with goptions::EC_WRONG_VERBOSITY_LEVEL. |
Definition at line 202 of file glogger.h.