Skip to main content
Version: 5.15.0

InsertLogV2

public BackendReturnObject InsertLogV2(string logType, Param param);
public BackendReturnObject InsertLogV2(string logType, Param param, int expirationDays);

Parameters

ValueTypeDescription
logTypestringType used to classify logs
paramstringParam that includes the content to be recorded in logs
expirationDaysintReserved date for deletion (If expirationDays is 10, the log is deleted automatically after 10 days; default setting is 90 days)

Description

  • Saves game logs.
  • The generated log can be checked in BACKND Console.
  • It may take up to 5 minutes to be registered to the console.
  • The max number of data that can be registered as Param is limited to 100.
  • For key values of Param, all special characters excluding (hyphen), _(underscore), (spacing) cannot be used.
  • nickname, game_id, indate cannot be used as key value.
Notes on Param key value settings

It is recommended to use fixed values for the Param keys based on the type of logging actions.

  • If you attempt to save data with a different key from the most recently saved log, a new schema type will be created, which may increase response time.
  • csv download is only available for data with the key of the most recently saved log, therefore data saved with a different key cannot be viewed in the csv download.

expirationDays

expirationDays is the grace period. (It is the same as graceDays in the existing InsertLog.) If you enter 10 for expirationDays, the log is deleted automatically after 10 days of insertion.
If you enter a number no more than 0 or do not enter any number, expirationDays is set to 90 (3 months).

Notes on expiration period settings

The expiration period for logs is fixed according to the expiration period of the first game log inserted for each log type, and it cannot be modified.

For example, if you set the first log for a specific action type to InsertLogV2(param, 7); and save it at least once, the expiration period for all subsequent logs will be fixed at 7 days, regardless of the parameter input values.

Example

Synchronous

Param param = new Param();
param.Add("n_n", "tableName");
Backend.GameLog.InsertLogV2("logType", param);

//If the desired period of log storage is up to 10 days
Backend.GameLog.InsertLogV2("logType", param, 10);

Asynchronous

Param param = new Param();
param.Add("n_n", "tableName");
Backend.GameLog.InsertLogV2("logType", param, (callback) => {
// Post-process
});

//If the desired period of log storage is up to 10 days
Backend.GameLog.InsertLogV2("logType", param, 10, (callback) => {
// Post-process
});

SendQueue

Param param = new Param();
param.Add("n_n", "tableName");
SendQueue.Enqueue(Backend.GameLog.InsertLogV2, "logType", param, (callback) => {
// Post-process
});

//If the desired period of log storage is up to 10 days
SendQueue.Enqueue(Backend.GameLog.InsertLogV2, "logType", param, 10, (callback) => {
// Post-process
});

ReturnCase

Success cases

When the log is created successfully
statusCode : 204
message : Success

Error cases

If param includes keys such as gamer_id, nickname, or inDate
statusCode : 405
errorCode : MethodNotAllowedParameterException
message : MethodNotAllowed {key}, Unavailable {key}

If there are keys in the param that starts with _ or numerics
statusCode : 405
errorCode : MethodNotAllowedParameterException
message : MethodNotAllowed {key}, Unavailable {key}

If matching key exists in the parameter, regardless of case sensitivity
statusCode : 405
errorCode : MethodNotAllowedParameterException
message : MethodNotAllowed {Duplicated key uppercase character}, Unavailable {duplicated key uppercase character}

If there are more than 100 data pieces added to param
statusCode : 428
errorCode : Precondition Required
message : Precondition Required Allowed the maximum length of key is 100

Sample Code

public void InsertLogV2Test() {
long money = 12345678;
int level = 100;
double hp = 123;
Dictionary<string, int> items = new Dictionary<string, int> { { "hpPotion", 12 }, { "mpPotion", 20 }, { "cook", 1 }, { "bomb", 20 } };
List<string> equip = new List<string>() { "hat12", "hat10", "shoes1", "costume20" };

Param param = new Param();
param.Add("money", money);
param.Add("level", level);
param.Add("hp", hp);

Param param2 = new Param();
param2.Add("items", items);
param2.Add("equip", equip);

var bro1 = Backend.GameData.Update("stats", new Where(), param);
var bro2 = Backend.GameData.Update("items", new Where(), param2);

// Log for error collection
Param logParam = new Param();

if(!bro1.IsSuccess()) {
logParam.Add("statsUpdateError", bro1.ToString());
}
if(!bro2.IsSuccess()) {
logParam.Add("itemsUpdateError", bro2.ToString());
}

logParam.Add("statsParam", param);
logParam.Add("itemsParam", param2);

var logBro = Backend.GameLog.InsertLogV2("updateLog", logParam);
Debug.Log(logBro.ToString());
}