# Collecting Game Logs

### 💻 스크립트에서 로그 기록

ServerScript 에서는 **SaveLog** 함수를,\
ClientScript 에서는 **SaveMyLog** 함수를 사용해서 로그를 기록할 수 있어요.

해당 함수가 호출된 시점의 시간, 해당 플레이어 정보, 인덱스 및 값이 기록돼요.

```lua
-- ServerScript
local function SaveLogData(player, value) 
    local playerID = player:GetPlayerID() 
		
    local dataKey = "Gold"  -- 기록할 로그의 데이터 키에요.
    local index_1 = 1       -- 기록할 로그의 1번 인덱스에요. 데이터 키의 하위 정보를 기록하고 싶다면 사용하고, 생략할 수도 있어요.
    local index_2 = 1000    -- 기록할 로그의 2번 인덱스에요. 데이터 키의 하위 정보를 기록하고 싶다면 사용하고, 생략할 수도 있어요.       
    
    Game:SaveLog(dataKey, playerID, value)
    Game:SaveLog(dataKey, index_1, playerID, value)
    Game:SaveLog(dataKey, index_1, index_2, playerID, value)
end     
Game:ConnectEventFunction("SaveLogData", SaveLogData)
```

```lua
-- ClientScript
local function SaveLogData(value) 	  
    local dataKey = "Gold"  -- 기록할 로그의 데이터 키에요.
    local index_1 = 1       -- 기록할 로그의 1번 인덱스에요. 데이터 키의 하위 정보를 기록하고 싶다면 사용하고, 생략할 수도 있어요.
    local index_2 = 1000    -- 기록할 로그의 2번 인덱스에요. 데이터 키의 하위 정보를 기록하고 싶다면 사용하고, 생략할 수도 있어요.        
    
    Game:SaveMyLog(dataKey, value)
    Game:SaveMyLog(dataKey, index_1, value)
    Game:SaveMyLog(dataKey, index_1, index_2, value)
end     
```

📌 로그의 **1번 인덱스**, **2번 인덱스**, **값** 은 number 형태만 기록할 수 있어요.

```lua
Game:SaveLog(dataKey, **index_1**, **index_2**, playerID, **value**)
```

아래 로그 기록 예시들을 참고해주세요.

1. 특정 플레이어가 <mark style="color:purple;">**어떤 기기로 월드를 플레이 했는지(value)**</mark> 기록하는 예시에요.

   ```lua
   -- ClientScript
   local function SaveLogData(value) 	 
       -- 기록할 로그의 데이터 키에요. 
       local dataKey = "ExperienceDevice"
   		
       -- 모바일 / PC 여부를 number 형태로 변환해서 기록해요.
       local isMobileDevice = Input:IsMobileTouchScreen() --Bool
       local value = -1     
       if     isMobileDevice then value = 0
       else                       value = 1
       end
   		
       Game:SaveMyLog(dataKey, value)
   end     
   ```

2. 특정 플레이어가 <mark style="color:orange;">**어떤 종류의 재화 (index\_1)**</mark> 를, <mark style="color:blue;">**어떤 소비처 (index\_2)**</mark> 에, <mark style="color:purple;">**얼마만큼 소비했는지 (value)**</mark> 를 기록하는 예시에요.

   ```lua
   -- ServerScript
   local function SaveLogData(player, assetType, usedPlace, value) 
       local playerID = player:GetPlayerID() 
   		
       -- 기록할 로그의 데이터 키에요.
       local dataKey = "PlayerAccount"                   
   		
       -- 소비한 재화 종류를 number 형태로 변환해서, 1번 인덱스에 기록해요.
       local index_1 = -1     
       if     assetType == "FreeAsset" then index_1 = 1
       elseif assetType == "PaidAsset" then index_1 = 2
       elseif assetType == "SubAsset"  then index_1 = 3
       end
   		
       -- 소비처 종류를 number 형태로 변환해서, 2번 인덱스에 기록해요.
       local index_2 = -1     
       if     usedPlace == "SkinShop"   then index_2 = 1
       elseif usedPlace == "WeaponShop" then index_2 = 2
       elseif usedPlace == "Gacha"      then index_2 = 3
       end               
   		
       Game:SaveLog(dataKey, index_1, index_2, playerID, value)
   end     
   Game:ConnectEventFunction("SaveLogData", SaveLogData)
   ```

***

### 📥 기록된 로그 데이터 다운로드

기록된 로그 데이터는, **월드 설정 페이지 > 로그 데이터 관리 페이지**에서\
**CSV 파일로 다운로드** 🔽 할 수 있어요.

<figure><img src="/files/uOikK1NAfQuQ37BHdm2x" alt=""><figcaption></figcaption></figure>

조회할 데이터를 입력 후, **\[CSV로 추출하기] 버튼**을 눌러주세요.

<figure><img src="/files/lffYM73FynJLtGbXtKsR" alt=""><figcaption></figcaption></figure>

* **데이터 키 값**

  👉 SaveLog, SaveMyLog 함수에 첫번째 인자로 사용되는 키를 입력해주세요.

  <figure><img src="/files/6uPulsHUNyvStt9EkB1l" alt=""><figcaption></figcaption></figure>

* **플레이어 ID**

  👉 특정 플레이어의 로그 값을 확인하고 싶다면,

  마이디토 > 닉네임 옆에서 확인할 수 있는 **#000000 로 이루어진 숫자** 를 입력해주세요.

  <div align="left"><figure><img src="/files/smdTdE3EHRLbSaGqdjH0" alt="" width="375"><figcaption></figcaption></figure></div>

  👉 전체 플레이어의 로그 값을 확인하고 싶은 경우엔, ‘전체’ 를 체크✅ 하면 돼요.

  <div align="left"><figure><img src="/files/oD33HJaidPlgZBgSlWu9" alt="" width="375"><figcaption></figcaption></figure></div>

* **기간**

  👉 로그가 기록된 기간 중, 조회하고 싶은 기간을 선택해주세요.

📄 CSV 파일에서 다음 데이터를 얻을 수 있어요.

<figure><img src="/files/k662a5nIRRyExgkM38sT" alt=""><figcaption></figcaption></figure>

* 해당 로그가 **기록된 시간** (타임스탬프 & UTC 시간)
* **플레이어** 닉네임 / 플레이어 ID
* 데이터 키 / 1번 인덱스 / 2번 인덱스 / 기록 값

***

### ✍ 기록 데이터 활용

기록된 데이터를 **지표 및 밸런싱에 활용**해보세요.

✅ 특정 플레이어가 **어떤 종류의 재화**를, **어떤 소비처**에, **얼마만큼 소비했는지**를 기록하는 경우,

* 인기가 없는 소비처를 파악해서, 개선이 필요한 부분을 찾거나
* 특정 플레이어에게서 부적절한 소비가 있지는 않았는지 확인해볼 수 있어요.

✅ 접속 시간대, 접속 유지 시간 등 **시간과 관련된 로그**를 기록하고 싶은 경우 **ostime 으로 기록**해보세요.\
기록한 ostime 값은 엑셀에서 다음과 같이 변환하여 확인할 수 있으니 참고해주세요.

1. ostime 기록 값에 아래 함수를 적용해주세요.

   <pre class="language-excel-formula"><code class="lang-excel-formula"><strong>=(((기록값 셀+32400)/60)/60)/24 + DATE(1970,1,1)
   </strong></code></pre>

   <figure><img src="/files/5OaZlq2ofrwdltEqHxha" alt=""><figcaption></figcaption></figure>

2. 함수를 적용한 셀에 다음과 같이 서식을 적용하면, 날짜와 시간을 표시할 수 있어요.

   <figure><img src="/files/juy93PyfezifgOcdJyOB" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ditoland-utplus.gitbook.io/ditoland/manual/collecting-game-logs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
