Assert, log, and debug of the gamebryo Engine

Source: Internet
Author: User

We need a robust engine in the game. How can we ensure the robustness of the engine? There are two main aspects: one is to minimize bugs, and the other is to discover and solve bugs as soon as possible after they occur. Like most engines, the GB engine has its own set of protection mechanisms. Includes assertions, log modules, and debug modules.

 

I. Assertions

The use of assertions allows developers to see the problem in the shortest time. Generally, assertions are only useful in debug mode. In release mode, we can record the error information in log. At this time, we need to redefine assert. The simplest thing is to define a macro. In GB, assert-related macros are defined in asserts. h. Ee_disable_asserts macro is used to control whether to enable assertions. ee_enable_release_assert is used to control whether to enable assertions in release mode. In general, it is not recommended to enable assertions in release mode. Three assertions are provided in GB: ee_assert_xxx, ee_verify_xxx and ee_fail_xxx. the first is used in debug mode, the second is used in release mode, and the last is used in case of detection failure.

 

2. Log

The log system is an essential part of a game engine. The most important purpose of building a log module is to understand the running status of the entire engine. First, we must know what should be recorded in the log. In general, the information recorded in the log can be divided by three levels: High, Medium, and low. Advanced information includes engine error information. For example, the crash information obtained through try catch is usually fatal errors, such as array out-of-bounds, memory access failure, and memory leakage. Medium refers to some non-fatal errors, such as data loading failure, network connection failure, and file opening failure. Low-level information includes some running prompts. Of course, we can also refine the level score as needed. In GB, the log level is divided into eight levels. We can perform different processing based on different levels. Generally, we store different types of log information in different files, it is recommended that the log information that causes the engine to crash be sent to a database over the network, which is advantageous for us to find the game errors.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.