InsertLogV2
public BackendReturnObject InsertLogV2(string logType, Param param);\ public BackendReturnObject InsertLogV2(string logType, Param param, int expirationDays);
While the previous InsertLog incurred both invocation costs and DB write throughput when saving logs, the improved InsertLogV2 only incurs invocation costs, allowing you to save logs without worrying about DB write charges.\
Parameters
Value | Type | Description |
---|---|---|
logType | string | Type used to classify logs |
param | string | Param that includes the content to be recorded in logs |
expirationDays | int | Reserved date for deletion (If expirationDays is 10, the log is deleted automatically after 10 days; default setting is 90 days) |
Description
- Saves game logs.
- You can check the created logs in BACKND Console and the game client.
- It may take up to 5 minutes to be registered to the console.
- For values of logType, all special characters excluding -(dashes), _(underscores), (spacing) cannot be used.
- The max number of data that can be registered as Param is limited to 100.
- For key values of param, all special characters excluding -(dashes), _(underscores), (spacing) cannot be used.
- nickname, game_id, indate cannot be used as key value.
When setting param key values, it is recommended to use fixed values based on log action types.
- If an attempt is made to save a log with a key value different from the most recently saved log, the log will be saved under a new schema type, which may result in a longer 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).
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
When the param contains gamer_id, nickname, or inDate as a key value\ statusCode : 405\ errorCode : MethodNotAllowedParameterException\ message : MethodNotAllowed {key}, This {key} cannot be used
When the param contains a key value starting with _ or a number\ statusCode : 405\ errorCode : MethodNotAllowedParameterException\ message : MethodNotAllowed {key}, This {key} cannot be used
When the param contains a key value starting with _ or a number\ statusCode : 405\ errorCode : MethodNotAllowedParameterException\ message : MethodNotAllowed {duplicate uppercase key}, This {duplicate uppercase key} cannot be used
When over 100 data was 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());
}