日志记录模块

此模块公开多个函数将消息输出到Substance Painter记录器。 根据消息的严重性,使用info()、warning()或error()。

若要更精细地控制记录参数(即严重性和通道),请使用log()。 函数info()、warning()和error()将输出到“Python”日志通道,而log()允许指定其他通道。

严重性级别为INFO、WARNING和ERROR的消息适用于最终用户,这些消息将显示在Substance 3D Painter的日志窗口中。 严重性级别为DBG_INFO、DBG_WARNING和DBG_ERROR的消息适用于开发人员,并将出现在日志文件中。

示例

import substance_painter.logging

# Simple log functions:
substance_painter.logging.info("Everyone knows that 2 + 2 is {0}.".format(2+2))
substance_painter.logging.warning("Maybe the user should look at this.")
substance_painter.logging.error("Letting the user know that something went wrong.")

# Log function with more options:
substance_painter.logging.log(
    substance_painter.logging.INFO,
    "Python",
    "An informative log message to the 'Python' channel.")

substance_painter.logging.log(
    substance_painter.logging.ERROR,
    "MyPlugin",
    "An error log message to the 'MyPlugin' channel.")

substance_painter.logging.error(消息:str) substance_painter.logging.error

在Substance 3D Painter记录器上记录级别为ERROR的消息。

参数: 消息 (str) — 要记录的错误消息。

substance_painter.logging.info(消息: str) substance_painter.logging.info

在Substance 3D Painter记录器上记录级别为INFO的消息。

参数: 消息 (str) — 要记录的消息。

substance_painter.logging.log(严重性,通道:str,消息:str) substance_painter.logging.log

在Substance 3D Painter记录器上记录严重性级别的消息。

参数:

  • 严重性 — 严重性级别可以是INFO、WARNING或ERROR(对于与最终用户相关的消息),或者DBG_INFO、DBG_WARNING或DBG_ERROR(对于与开发人员相关的消息)。
  • 通道 (str) — 要登录的通道。 该名称可以是任何允许标识消息来源的名称,例如插件的名称。
  • 消息 (str) — 要记录的消息。

substance_painter.logging.warning(消息:str) substance_painter.logging.warning

在Substance 3D Painter记录器上记录级别为WARNING的消息。

参数: 消息 (str) — 要记录的警告消息。

recommendation-more-help
substance-3d-dev-help-painter-python-guide