Skip to main content
Version: SDK-5.11.4

Saving Game Logs

1. Write a game log insertion method

Add content to the GameLogInsert method in BackendGameLog.cs written in Pre-arrangements.

BackendGameLog.cs

Before editing

    public void GameLogInsert() {
// Adds logic of Step 2. Saving Game Logs
}

After editing

    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 editing

    async void Test() {
await Task.Run(() => {
BackendLogin.Instance.CustomLogin("user1", "1234");

// Adds content of saving game logs

Debug.Log("Test complete.");
});
}

After editing

    async void Test() {
await Task.Run(() => {
BackendLogin.Instance.CustomLogin("user1", "1234");

BackendGameLog.Instance.GameLogInsert(); // [Addition] Function for saving game logs

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 'Successfully inserted the game log. : 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.