Usage of the Logger
Using the Default Logger of AcuiRT
Create a Logger
-
When using the default logger, you need to create an instance of the
AcuiRTDefaultLoggerclass from theacuirt.loggermodule. -
Specify
nameand set the logger’s name.from acuirt.logger import AcuiRTDefaultLogger
logger = AcuiRTDefaultLogger(name="AcuiRT")
Apply the logger
-
You can pass a logger to the following function.
summary = convert_model(resnet, config, path, False, data, logger=logger)
model = load_runtime_modules(resnet, summary, path, logger=logger)
Change the Minimum Log Level
-
To change the minimum log level, set
min_severityin the argument. -
The correspondence table of log levels is as follows.
TensorRT ILogger Log Level Python logging Log Level ILogger.INTERNAL_ERROR logging.CRITICAL ILogger.ERROR logging.ERROR ILogger.WARNING logging.WARNING ILogger.INFO logging.INFO ILogger.VERBOSE logging.DEBUG
Change the output format
-
If you want to change the output format, please set it using the
set_formatter()function.logger = AcuiRTDefaultLogger()
formatter = logging.Formatter(
"[%(asctime)s]: %(levelname)s: %(message)s",
)
logger.set_formatter(formatter)
Add Output Destination
-
If you want to add an output destination, set it from the
set_handler()function. -
If you also want to specify the output format, set the
formatterargument.import sys
handler = logging.StreamHandler(sys.stdout)
logger.set_handler(handler)
Use a custom logger
- The
intelligence/acuirt/use_custom_logger.pyin aibooster-examples shows an example of applying a custom logger to AcuiRT.