Class which manages logging of TensorRT tools and samples. More...
Classes | |
class | TestAtom |
Opaque handle that holds logging information for a particular test. More... | |
Public Types | |
enum | TestResult { TestResult::kRUNNING, TestResult::kPASSED, TestResult::kFAILED, TestResult::kWAIVED } |
Represents the state of a given test. More... | |
enum | Severity : int32_t { Severity::kINTERNAL_ERROR = 0, Severity::kERROR = 1, Severity::kWARNING = 2, Severity::kINFO = 3, Severity::kVERBOSE = 4 } |
Public Member Functions | |
Logger (Severity severity=Severity::kWARNING) | |
nvinfer1::ILogger & | getTRTLogger () |
Forward-compatible method for retrieving the nvinfer::ILogger associated with this Logger. More... | |
void | log (Severity severity, const char *msg) override |
Implementation of the nvinfer1::ILogger::log() virtual method. More... | |
void | setReportableSeverity (Severity severity) |
Method for controlling the verbosity of logging output. More... | |
Severity | getReportableSeverity () const |
Static Public Member Functions | |
static TestAtom | defineTest (const std::string &name, const std::string &cmdline) |
Define a test for logging. More... | |
static TestAtom | defineTest (const std::string &name, int argc, char const *const *argv) |
A convenience overloaded version of defineTest() that accepts an array of command-line arguments as input. More... | |
static void | reportTestStart (TestAtom &testAtom) |
Report that a test has started. More... | |
static void | reportTestEnd (const TestAtom &testAtom, TestResult result) |
Report that a test has ended. More... | |
static int | reportPass (const TestAtom &testAtom) |
static int | reportFail (const TestAtom &testAtom) |
static int | reportWaive (const TestAtom &testAtom) |
static int | reportTest (const TestAtom &testAtom, bool pass) |
Static Private Member Functions | |
static const char * | severityPrefix (Severity severity) |
returns an appropriate string for prefixing a log message with the given severity More... | |
static const char * | testResultString (TestResult result) |
returns an appropriate string for prefixing a test result message with the given result More... | |
static std::ostream & | severityOstream (Severity severity) |
returns an appropriate output stream (cout or cerr) to use with the given severity More... | |
static void | reportTestResult (const TestAtom &testAtom, TestResult result) |
method that implements logging test results More... | |
static std::string | genCmdlineString (int argc, char const *const *argv) |
generate a command line string from the given (argc, argv) values More... | |
Private Attributes | |
Severity | mReportableSeverity |
Class which manages logging of TensorRT tools and samples.
This class provides a common interface for TensorRT tools and samples to log information to the console, and supports logging two types of messages:
The advantage of having all samples use this class for logging as opposed to emitting directly to stdout/stderr is that the logic for controlling the verbosity and formatting of sample output is centralized in one location.
In the future, this class could be extended to support dumping test results to a file in some standard format (for example, JUnit XML), and providing additional metadata (e.g. timing the duration of a test run).
TODO: For backwards compatibility with existing samples, this class inherits directly from the nvinfer1::ILogger interface, which is problematic since there isn't a clean separation between messages coming from the TensorRT library and messages coming from the sample.
In the future (once all samples are updated to use Logger::getTRTLogger() to access the ILogger) we can refactor the class to eliminate the inheritance and instead make the nvinfer1::ILogger implementation a member of the Logger object.
|
strong |
|
stronginherited |
The severity corresponding to a log message.
|
inline |
|
inline |
Forward-compatible method for retrieving the nvinfer::ILogger associated with this Logger.
TODO Once all samples are updated to use this method to register the logger with TensorRT, we can eliminate the inheritance of Logger from ILogger
|
inlineoverridevirtual |
Implementation of the nvinfer1::ILogger::log() virtual method.
Note samples should not be calling this function directly; it will eventually go away once we eliminate the inheritance from nvinfer1::ILogger
Implements nvinfer1::ILogger.
|
inline |
Method for controlling the verbosity of logging output.
severity | The logger will only emit messages that have severity of this level or higher. |
|
inlinestatic |
Define a test for logging.
[in] | name | The name of the test. This should be a string starting with "TensorRT" and containing dot-separated strings containing the characters [A-Za-z0-9_]. For example, "TensorRT.sample_googlenet" |
[in] | cmdline | The command line used to reproduce the test |
|
inlinestatic |
A convenience overloaded version of defineTest() that accepts an array of command-line arguments as input.
[in] | name | The name of the test |
[in] | argc | The number of command-line arguments |
[in] | argv | The array of command-line arguments (given as C strings) |
|
inlinestatic |
Report that a test has started.
[in] | testAtom | The handle to the test that has started |
|
inlinestatic |
Report that a test has ended.
[in] | testAtom | The handle to the test that has ended |
[in] | result | The result of the test. Should be one of TestResult::kPASSED, TestResult::kFAILED, TestResult::kWAIVED |
|
inline |
|
inlinestaticprivate |
returns an appropriate string for prefixing a log message with the given severity
|
inlinestaticprivate |
returns an appropriate string for prefixing a test result message with the given result
|
inlinestaticprivate |
returns an appropriate output stream (cout or cerr) to use with the given severity
|
inlinestaticprivate |
method that implements logging test results
|
inlinestaticprivate |
generate a command line string from the given (argc, argv) values
|
private |