1. Introduction to the script that calls the output log method
If you need to print the log to a file or console, you can call the method in the script NFLogModule.cpp . Since there are too many methods in this script, I will not introduce them one by one. If necessary, you can take a look at the specific implementation process yourself. The output and print log methods called by the author in the following sections are all from this script.
Two, LogInfo () method
1. Initialize the m_pLogModule field.
2. The author wrote the test code in a test method. The code in the two red boxes in the figure below is the test output log code written by the author. You can write corresponding statements in the corresponding methods according to your own needs for testing.
After writing the two lines of code in the red box above, just save the script.
3. Make sure that the project name of the output log file is NFLoginLogicPlugin , which must be in the Plugin.xml file.
4. Click "Generate" - "Generate Solution" in VS and wait for the project compilation to complete.
5. After the project is compiled, double-click the " rund.bat " file to start running the server.
6. After waiting for a minute or two, you will see the corresponding effect in the corresponding file.
Three, LogError () method
Since this and the following method tests are the same as the second step of the LogInfo() method test process, so I will directly talk about the conclusion below, not the specific process. If you have any questions, you can directly ask the author under the comment area.
Four, LogDebug () method
Five, LogWarning () method
Six, LogFatal () method
Seven, the strings are spliced, and then output together
8. In the corresponding server window, you can see the output log
Since the project file where the test output log script file is located is named NFLoginLogicPlugin , which is included in this element tag, you can view the corresponding output log in the corresponding server window. So the author's output log can be viewed in the NFLogin4 window. The third picture below is the test log output by the author.
Nine, output the log to the corresponding custom file
1. This is the log output path to the corresponding configuration file.
2. Open the file corresponding to the corresponding path. Here, the author opened a file at random.
3. We can modify the corresponding file name here.
Previous: Open source game server framework NoahGameFrame (NF) client environment construction (3)
Next: Open source game server framework NoahGameFrame (NF) client Log log system (5)