![]() |
VR-Vantage 3.1 API Documentation
|
Go to the source code of this file.
Classes | |
| class | jrm::DebugStreamAdapter |
This class implements a mechanism that logs to an arbitrary ostream. More... | |
Namespaces | |
| namespace | jrm |
Macros | |
| #define | JRM_DBG1_STMT JRM_DBG(jrm::DebugLevel_Debug1) |
| These are shorthand for declaring debug statements at the globally-defined levels. | |
| #define | JRM_DBG2_STMT JRM_DBG(jrm::DebugLevel_Debug2) |
| These are shorthand for declaring debug statements at the globally-defined levels. | |
| #define | JRM_DBG3_STMT JRM_DBG(jrm::DebugLevel_Debug3) |
| These are shorthand for declaring debug statements at the globally-defined levels. | |
| #define | JRM_DBG4_STMT JRM_DBG(jrm::DebugLevel_Debug4) |
| These are shorthand for declaring debug statements at the globally-defined levels. | |
| #define | JRM_DBG5_STMT JRM_DBG(jrm::DebugLevel_Debug5) |
| These are shorthand for declaring debug statements at the globally-defined levels. | |
| #define | JRM_ERR JRM_LOG(jrm::DebugLevel_LogError) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded. | |
| #define | JRM_CRI JRM_LOG(jrm::DebugLevel_LogCritical) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded. | |
| #define | JRM_WRN JRM_LOG(jrm::DebugLevel_LogWarning) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded. | |
| #define | JRM_INF JRM_LOG(jrm::DebugLevel_LogInfo) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded. | |
| #define | JRM_DBG1 JRM_LOG(jrm::DebugLevel_Debug1) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded. | |
| #define | JRM_DBG2 JRM_LOG(jrm::DebugLevel_Debug2) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded. | |
| #define | JRM_DBG3 JRM_LOG(jrm::DebugLevel_Debug3) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded. | |
| #define | JRM_DBG4 JRM_LOG(jrm::DebugLevel_Debug4) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded. | |
| #define | JRM_DBG5 JRM_LOG(jrm::DebugLevel_Debug5) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded. | |
| #define | JRM_ERR2(insertions) JRM_LOG2(jrm::DebugLevel_LogError, std::cerr, insertions) |
| Writes the given stream insertions to both the log and associated stream. | |
| #define | JRM_CRI2(insertions) JRM_LOG2(jrm::DebugLevel_LogCritical, std::cout, insertions) |
| Writes the given stream insertions to both the log and associated stream. | |
| #define | JRM_WRN2(insertions) JRM_LOG2(jrm::DebugLevel_LogWarning, std::cerr, insertions) |
| Writes the given stream insertions to both the log and associated stream. | |
| #define | JRM_INF2(insertions) JRM_LOG2(jrm::DebugLevel_LogInfo, std::cout, insertions) |
| Writes the given stream insertions to both the log and associated stream. | |
| #define | JRM_HERE (boost::filesystem::path(__FILE__).filename().string() + "[" + boost::lexical_cast<std::string>(__LINE__) + "]") |
| Expands to a std::string containing the current file name, line number, and function. | |
| #define | JRM_DBG(level) |
| Executes the next statement if module debugging is "on" and the module debug level meets or exceeds the given statement level. | |
| #define | JRM_LOG(level) JRM_LOG_HELPER((level)) |
| Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the specified threshold debug level is met or exceeded. | |
| #define | JRM_LOG_HELPER(level) |
| #define | JRM_LOG2(level, ostream, insertions) |
| Applies the given stream insertions to both the log and the given stream. | |
Enumerations | |
| enum | jrm::DebugLevel { jrm::DebugLevel_Off, jrm::DebugLevel_UseGlobal, jrm::DebugLevel_LogError, jrm::DebugLevel_LogCritical, jrm::DebugLevel_LogWarning, jrm::DebugLevel_LogInfo, jrm::DebugLevel_Debug1, jrm::DebugLevel_Debug2, jrm::DebugLevel_Debug3, jrm::DebugLevel_Debug4, jrm::DebugLevel_Debug5, jrm::DebugLevel_CustomBase } |
| Defines debug levels having special meaning. More... | |
Functions | |
| JrmUtilsDllLinkage std::string | jrm::ToString (const DebugLevel &value) |
| Returns a human-readable string representation of the given value. | |
Variables | |
| static DebugLevel | jrm::ModuleDebugLevel = DebugLevel_UseGlobal |
| Threshold value used to control debug code execution and logging verbosity for the current "module" (i.e. | |
| JrmUtilsDllLinkage DebugLevel | jrm::GlobalDebugLevel |
| Threshold value used to control debug code execution and logging verbosity for any module whose module-relative debug level is set to DebugLevel_UseGlobal. | |
2006 - 2013. All rights reserved.
This module implements a logging mechanism that may be throttled based upon module-relative and / or global thresholds.
This module implements:
A simple "debug log" mechanism that writes formatted messages to an arbitrary ostream. The format is a table that includes these columns (items a-c are auto-generated): a. A high-resolution timestamp. b. Invoking thread ID. c. Invoking code location (i.e. file name, line number, and function name). d. An arbitrary message.
The log mechanism leverages the debug level mechanism to be more verbose at higher debug levels.
Example usage:
Overview:
In general, each module or main() method should add this code once to use the mechanisms described here:
// Must call this for logging to be enabled. Only the first call actually creates the object, so main() should call it early to preempt any calls by subordinate modules.
// Optionally takes an ostream to which to write. Default is std::cout.
jrm::DebugStreamAdapter::Create();
// Optional, but may be useful to set in main() from a command line parameter or environment variable. Default is jrm::DebugLevel_Info.
jrm::GlobalDebugLevel = jrm::DebugLevel_Info;
Debug statements:
By default, the module-relative debug level is set to a value meaning to use whatever the global debug level is.
This allows a module to use the log mechanism without any added effort. However you may change this on a per-module basis by setting
jrm::ModuleDebugLevel directly, e.g. "jrm::ModuleDebugLevel = jrm::DebugLevel_Off" to disable the mechanism for the current compilation unit.
1. JRM_DBG1_STMT
{
// Multiple lines of debugging code that is only executed at debug levels >= jrm::DebugLevel_Debug1.
}
2. JRM_DBG3_STMT singleDbgStmt();
Log statements:
For log statements to be written anywhere, first call:
jrm::DebugStreamAdapter::Create();
Otherwise logging will be disabled and statements will simply be ignored.
1. JRM_INF << "stuff to log at log level " << jrm::DebugLevel_Info << endl;
2. JRM_ERR << "log an error!" << endl;
3. JRM_DBG3 << "log this when we've cranked-up the log level" << endl;
| #define JRM_DBG1_STMT JRM_DBG(jrm::DebugLevel_Debug1) |
These are shorthand for declaring debug statements at the globally-defined levels.
Use these per the examples given in the Detailed Description of this file.
| #define JRM_DBG2_STMT JRM_DBG(jrm::DebugLevel_Debug2) |
These are shorthand for declaring debug statements at the globally-defined levels.
Use these per the examples given in the Detailed Description of this file.
| #define JRM_DBG3_STMT JRM_DBG(jrm::DebugLevel_Debug3) |
These are shorthand for declaring debug statements at the globally-defined levels.
Use these per the examples given in the Detailed Description of this file.
| #define JRM_DBG4_STMT JRM_DBG(jrm::DebugLevel_Debug4) |
These are shorthand for declaring debug statements at the globally-defined levels.
Use these per the examples given in the Detailed Description of this file.
| #define JRM_DBG5_STMT JRM_DBG(jrm::DebugLevel_Debug5) |
These are shorthand for declaring debug statements at the globally-defined levels.
Use these per the examples given in the Detailed Description of this file.
| #define JRM_ERR JRM_LOG(jrm::DebugLevel_LogError) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded.
Use these per the examples given in the Detailed Description of this file, e.g.:
| #define JRM_CRI JRM_LOG(jrm::DebugLevel_LogCritical) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded.
Use these per the examples given in the Detailed Description of this file, e.g.:
| #define JRM_WRN JRM_LOG(jrm::DebugLevel_LogWarning) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded.
Use these per the examples given in the Detailed Description of this file, e.g.:
| #define JRM_INF JRM_LOG(jrm::DebugLevel_LogInfo) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded.
Use these per the examples given in the Detailed Description of this file, e.g.:
| #define JRM_DBG1 JRM_LOG(jrm::DebugLevel_Debug1) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded.
Use these per the examples given in the Detailed Description of this file, e.g.:
| #define JRM_DBG2 JRM_LOG(jrm::DebugLevel_Debug2) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded.
Use these per the examples given in the Detailed Description of this file, e.g.:
| #define JRM_DBG3 JRM_LOG(jrm::DebugLevel_Debug3) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded.
Use these per the examples given in the Detailed Description of this file, e.g.:
| #define JRM_DBG4 JRM_LOG(jrm::DebugLevel_Debug4) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded.
Use these per the examples given in the Detailed Description of this file, e.g.:
| #define JRM_DBG5 JRM_LOG(jrm::DebugLevel_Debug5) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the named debug level is met or exceeded.
Use these per the examples given in the Detailed Description of this file, e.g.:
| #define JRM_ERR2 | ( | insertions | ) | JRM_LOG2(jrm::DebugLevel_LogError, std::cerr, insertions) |
Writes the given stream insertions to both the log and associated stream.
Applies the given stream insertions to:
main() function to be sure a message is seen, either in the log or on a standard stream.| [in] | insertions | Chain of stream insertion operations to apply (without the usual leading stream) e.g.: "stuff you want " << " to be sure " << " gets logged " << endl
|
| #define JRM_CRI2 | ( | insertions | ) | JRM_LOG2(jrm::DebugLevel_LogCritical, std::cout, insertions) |
Writes the given stream insertions to both the log and associated stream.
Applies the given stream insertions to:
main() function to be sure a message is seen, either in the log or on a standard stream.| [in] | insertions | Chain of stream insertion operations to apply (without the usual leading stream) e.g.: "stuff you want " << " to be sure " << " gets logged " << endl
|
| #define JRM_WRN2 | ( | insertions | ) | JRM_LOG2(jrm::DebugLevel_LogWarning, std::cerr, insertions) |
Writes the given stream insertions to both the log and associated stream.
Applies the given stream insertions to:
main() function to be sure a message is seen, either in the log or on a standard stream.| [in] | insertions | Chain of stream insertion operations to apply (without the usual leading stream) e.g.: "stuff you want " << " to be sure " << " gets logged " << endl
|
| #define JRM_INF2 | ( | insertions | ) | JRM_LOG2(jrm::DebugLevel_LogInfo, std::cout, insertions) |
Writes the given stream insertions to both the log and associated stream.
Applies the given stream insertions to:
main() function to be sure a message is seen, either in the log or on a standard stream.| [in] | insertions | Chain of stream insertion operations to apply (without the usual leading stream) e.g.: "stuff you want " << " to be sure " << " gets logged " << endl
|
| #define JRM_HERE (boost::filesystem::path(__FILE__).filename().string() + "[" + boost::lexical_cast<std::string>(__LINE__) + "]") |
Expands to a std::string containing the current file name, line number, and function.
| #define JRM_DBG | ( | level | ) |
Executes the next statement if module debugging is "on" and the module debug level meets or exceeds the given statement level.
The next statement may be a compound statement (i.e. enclosed in curly braces) to guard multiple lines of debug code based upon the debugging level.
| [in] | level | The debug level at which the module-relative debug threshold must be set (or above) for the next statement to be executed. This should be a jrm::DebugLevel value, as it defines levels with global meaning. |
| #define JRM_LOG | ( | level | ) | JRM_LOG_HELPER((level)) |
Logs the stream insertions that follow to the stream passed to jrm::DebugStreamAdapter::Create() when the specified threshold debug level is met or exceeded.
| [in] | level | The debug level at which the module-relative debug threshold must be set (or above) for the next statement to be executed. This should be a jrm::DebugLevel value, as it defines levels with global meaning. |
| #define JRM_LOG_HELPER | ( | level | ) |
| #define JRM_LOG2 | ( | level, | |
| ostream, | |||
| insertions | |||
| ) |
Applies the given stream insertions to both the log and the given stream.
Applies the given stream insertions to:
| [in] | level | The debug level at which the module-relative debug threshold must be set (or above) for the next statement to be executed. This should be a jrm::DebugLevel value, as it defines levels with global meaning. |
| [in,out] | ostream | Stream to which to apply the given insertions in the absence of the log, e.g. std::cout, std::cerr. |
| [in] | insertions | Chain of stream insertion operations to apply (without the usual leading stream) e.g.: "stuff you want " << " to be sure " << " gets logged " << endl
|