Skip to main content
Version: v2510

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 AcuiRTDefaultLogger class from the acuirt.logger module.

  • Specify name and 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_severity in the argument.

  • The correspondence table of log levels is as follows.

    TensorRT ILogger Log LevelPython logging Log Level
    ILogger.INTERNAL_ERRORlogging.CRITICAL
    ILogger.ERRORlogging.ERROR
    ILogger.WARNINGlogging.WARNING
    ILogger.INFOlogging.INFO
    ILogger.VERBOSElogging.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 formatter argument.

    import sys
    handler = logging.StreamHandler(sys.stdout)
    logger.set_handler(handler)

Use a custom logger

  • The intelligence/acuirt/use_custom_logger.py in aibooster-examples shows an example of applying a custom logger to AcuiRT.