UDF Log API Overview
Logging APIs are exposed for Python UDFs. You need to import the flow_func module to use these APIs. Use the defined logger object within this module to call its encapsulated logging APIs of different severity levels.
Log Type |
Application Scenarios |
Log Level |
Log Macro |
|---|---|---|---|
Run log |
Run logs record abnormal status and operations, key events, and resource usage during system running. |
ERROR/INFO |
Error-Level Log Macro of Run Logs/Info-Level Log Macro of Run Logs |
Debug log |
Debug logs record the following scenarios (including but not limited to these scenarios): - Entrance and exit of all calls such as API and function calls - Operation entrance and prerequisite setting - Start or timeout of a timer - Before and after status setting and status transfer condition judgment - Business-related resource statistics, business processing entrance/exit, and performance computing statistics - All processing failures and exceptions Debug logs record code-related information for R&D engineers to locate faults. |
ERROR/WARN/INFO/DEBUG |
Error-Level Log Macro of Debug Logs/Warn-Level Log Macro of Debug Logs/Error-Level Log Macro of Debug Logs/Debug-Level Log Macro of Debug Logs |
Log usage example:
1 2 | import dataflow.flow_func as ff ff.logger.info("This is a test info log :%s %d %f.", "test_str", 100, 0.1) |
For details about how to change the log level, see the usage of ASCEND_GLOBAL_LOG_LEVEL and ASCEND_MODULE_LOG_LEVEL in Environment Variables. User UDF logs correspond to the APP module. You can control the APP log level based on the module.
For example, if you want to enable the Info log function of a customized UDF, run the following command to enable the Info log function of the APP module:
export ASCEND_MODULE_LOG_LEVEL=APP=1
You can also run the following command to enable the Info log function for all modules:
export ASCEND_GLOBAL_LOG_LEVEL=1
During UDF execution, flow control is performed on APP module logs to prevent too many logs from affecting framework logs and execution performance. The restriction rules are as follows.
API Type |
Debug log |
Debug Log |
Debug Log |
Debug Log |
Run Log |
Run Log |
|---|---|---|---|---|---|---|
Level |
debug |
info |
warn |
error |
run_info |
run_error |
DEBUG |
Unlimited |
Unlimited |
Unlimited |
Unlimited |
50/400 |
50/400 |
INFO |
Not print |
100/1000 |
100/1000 |
100/1000 |
100/1000 |
100/1000 |
WARN |
Not print |
Not print |
50/400 |
50/400 |
50/400 |
50/400 |
ERROR |
Not print |
Not print |
Not print |
50/400 |
50/400 |
50/400 |
Note: Each independent process outputs A logs per second, with a cumulative ceiling of B. Values are displayed as [A/B] in the table above. The cumulative ceiling refers to the maximum instantaneous log output volume available when the process has stopped printing logs for a period of time.