8. Logging for the RoboMaster SDK¶
8.1. Configure the log level¶
The default log level of the RoboMaster SDK is ERROR. Users can change it as needed.
The statement for setting the log level in
/examples/01_robot/00_logger.py
is as follows::logger.setLevel(logging.ERROR)
You can change it to this statement based on their needs::
logger.setLevel(logging.WARNING)
You can also change the statement to the following::
logger.setLevel(logging.INFO)
8.2. Use log files¶
If users encounter a problem during use, they need to write the log to a file and provide the log file to technical support personnel.
Generation method of log files
Add this statement at the beginning of the program::
robomaster.enable_logging_to_file()
Run the program.
The SDK will automatically generate a system log file and store it in a directory at the same level as the program. The name format of log files is as follows::
RoboMasterSDK_YYYYMMDDHHMMSS_log.txt
Send the generated system log file to developer@dji.com by using this email template::
xxxxxxxx xxxxxxxx xxxxxxxx
Sample code
- Refer to the example in the
/examples/01_robot/00_logger.py
directory of SDK code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import robomaster
from robomaster import robot
if __name__ == '__main__':
robomaster.enable_logging_to_file()
# 如果本地IP 自动获取不正确,手动指定本地IP地址
# robomaster.config.LOCAL_IP_STR = "192.168.2.20"
ep_robot = robot.Robot()
# 指定连接方式为AP 直连模式
ep_robot.initialize(conn_type='rndis')
version = ep_robot.get_version()
print("Robot version: {0}".format(version))
ep_robot.close()
|
After running the program, the SDK will automatically generate a system log file in a directory at the same level as the program, as shown in the figure below: