Saving Game Logs
1. Write a method for inserting game logs
Add content to the GameLogInsert method in BackendGameLog.cs written in Pre-arrangements.
BackendGameLog.cs
Before modification
public void GameLogInsert()
{
// Add logic of Step 2. Saving Game Logs
}
After modification
public void GameLogInsert()
{
Param param = new Param();
param.Add("clearStage", 1);
param.Add("currentMoney", 100000);
Debug.Log("Attempting to insert game log.");
var bro = Backend.GameLog.InsertLog("ClearStage", param);
if (bro.IsSuccess() == false)
{
Debug.LogError("An error occurred while inserting the game log. : " + bro);
return;
}
Debug.Log("Successfully inserted game log. : " + bro);
}
2. Add method call to BackendManager.cs
BackendManager, which is automatically called when the game is executed, must be used to call this method.
Add it so that the method may be called after BACKND initialization and BACKND login.
BackendManager.cs
Before modification
void Test()
{
BackendLogin.Instance.CustomLogin("user1", "1234");
// Add content of saving game logs
Debug.Log("Test complete.");
}
After modification
void Test()
{
BackendLogin.Instance.CustomLogin("user1", "1234");
BackendGameLog.Instance.GameLogInsert(); // [Addition] Game log saving function
Debug.Log("Test complete.");
}
3. Test in Unity
After editing the script, execute Unity debugging and check the console log of Unity.
The method has been successfully called when the log displays 'Game log insertion successful. : statusCode : 204'.
When errors, such as statusCode : 400, 404, and 409, occur instead of the above log, you can check which errors caused the failure in InsertLog error case.
4. Check in the console
When a log showing success appears in the game log, go to BACKND Console and under BACKND Base > Log Management
, click Action Type and select the inserted action type.