Open source game server framework NoahGameFrame (NF) server-side Log log system (4)

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.
insert image description here

Two, LogInfo () method

1. Initialize the m_pLogModule field.
insert image description here
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.
insert image description here
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.
insert image description here

insert image description here
insert image description here
4. Click "Generate" - "Generate Solution" in VS and wait for the project compilation to complete.
insert image description here
5. After the project is compiled, double-click the " rund.bat " file to start running the server.
insert image description here
6. After waiting for a minute or two, you will see the corresponding effect in the corresponding file.
insert image description here

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.
insert image description here
insert image description here

Four, LogDebug () method

insert image description here
insert image description here

Five, LogWarning () method

insert image description here
insert image description here

Six, LogFatal () method

insert image description here
insert image description here

Seven, the strings are spliced, and then output together

insert image description here
insert image description here

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.
insert image description here
insert image description hereinsert image description here

Nine, output the log to the corresponding custom file

1. This is the log output path to the corresponding configuration file.
insert image description here
2. Open the file corresponding to the corresponding path. Here, the author opened a file at random.
insert image description here
3. We can modify the corresponding file name here.insert image description 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)

Guess you like

Origin blog.csdn.net/jianjianshini/article/details/127250592