Project

General

Profile

Game Log » History » Revision 4

Revision 3 (Master Chief, 2020-02-11 05:50) → Revision 4/5 (Master Chief, 2020-02-11 08:20)

<h1>게임 로그</h1> 로그<a class="wiki-anchor" href="#게임-로그">&para;</a></h1> 

 <p>로그는 게임 서비스에서 매우 중요한 역할을 차지합니다. <u>LE_HACK</u> , <u>LE_CLIENT_IN</u> , <u>LE_CLIENT_OUT</u> , <u>LE_CHAT_CHANNEL</u> , <u>LE_ROOM_CREATE</u> , <u>LE_ROOM_JOIN</u> , <u>LE_ROOM_END</u> , <u>LE_ITEM_BUY</u> , <u>LE_ITEM_SELL</u> , <u>LE_ITEM_DESTRUCT</u> , <u>LE_ITEM_USE</u> 등은 서비스 운영에 반드시 필요한 것들이며 <u>LE_BUG</u> 역시 서비스 안정화에 필요합니다.</p> 

 <blockquote> 
 <p>어떠한 뛰어난 개발자라도 완벽히 모든 상황을 예측할수 없습니다. 서버 코드 작성중에 조건문 분기시 들어가서는 안되는 위치에 <u>LE_BUG</u> 를 남겨주세요. 파일 위치, 라인 위치, 추적을 위한 오류 메세지 등이 필요합니다.</p> 
 </blockquote> 

 <p>이제 서버 개발자가 할일은 서식있는 로그를 남기는 것입니다.</p> 

 <pre> 
 <code class="cpp syntaxhl"><span class="k">enum</span> <span class="n">LOG_EVENT_TYPE</span> <span class="p">{</span> 
     <span class="n">LE_SERVER_START</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> 
     <span class="n">LE_SERVER_STOP</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> 
     <span class="n">LE_HACK</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> 
     <span class="n">LE_BUG</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> 
     <span class="n">LE_CLIENT_IN</span> <span class="o">=</span> <span class="mi">6</span><span class="p">,</span> 
     <span class="n">LE_CLIENT_OUT</span> <span class="o">=</span> <span class="mi">7</span><span class="p">,</span> 
     <span class="n">LE_CHAT_CHANNEL</span> <span class="o">=</span> <span class="mi">10</span><span class="p">,</span> 
     <span class="n">LE_ROOM_CREATE</span> <span class="o">=</span> <span class="mi">26</span><span class="p">,</span> 
     <span class="n">LE_ROOM_JOIN</span> <span class="o">=</span> <span class="mi">27</span><span class="p">,</span> 
     <span class="p">...</span> 
 <span class="p">};</span> 
 </code></pre> 

 <p><strong>LE_HACK 필드 서식</strong></p> 

 <p><u>LF_AID</u> , iAccountId, <u>LF_DEBUG</u> , iLineNumber, <u>LF_STRING</u> , szMessage</p> 

 <p><strong>LE_BUG 필드 서식</strong></p> 

 <p><u>LF_AID</u> , iAccountId, <u>LF_DEBUG</u> , iLineNumber, <u>LF_STRING</u> , szMessage</p> 

 <p><strong>LE_CLIENT_IN 필드 서식</strong></p> 

 <p><u>LF_AID</u> , iAccountId, <u>LF_LOGIN_ID</u> , szLoginId</p> 

 <p><strong>LE_CLIENT_OUT 필드 서식</strong></p> 

 <p><u>LF_AID</u> , iAccountId, <u>LF_LOGIN_ID</u> , szLoginId</p> 

 <p><strong>LE_CHAT_CHANNEL 필드 서식</strong></p> 

 <p><u>LF_AID</u> , iAccountId, <u>LF_LOGIN_ID</u> , szLoginId, <u>LF_CHANNEL_ID</u> , iChannelId, <u>LF_STRING</u> , szMessage</p> 

 <p><strong>LE_ROOM_CREATE 필드 서식</strong></p> 

 <p><u>LF_AID</u> , iAccountId, <u>LF_ROOM_ID</u> , iRoomId, <u>LF_STAGE_ID</u> , iStageId, <u>LF_STRING</u> , szMessage</p> 

 <p><strong>LE_ROOM_JOIN 필드 서식</strong></p> 

 <p><u>LF_AID</u> , iAccountId, <u>LF_ROOM_ID</u> , iRoomId, <u>LF_STAGE_ID</u> , iStageId, <u>LF_STRING</u> , szMessage</p> 

 <pre> 
 <code class="cpp syntaxhl"><span class="k">enum</span> <span class="n">LOG_EVENT_TYPE</span> <span class="p">{</span> 
     <span class="n">LF_NONE</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> 
     <span class="n">LF_DEBUG</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> 
     <span class="n">LF_SUCCESS</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> 
     <span class="n">LF_FAIL</span> <span class="o">=</span> <span class="mi">4</span><span class="p">,</span> 
     <span class="n">LF_TIME</span> <span class="o">=</span> <span class="mi">5</span><span class="p">,</span> 
     <span class="n">LF_STRING</span> <span class="o">=</span> <span class="mi">6</span><span class="p">,</span> 
     <span class="n">LF_AID</span> <span class="o">=</span> <span class="mi">7</span><span class="p">,</span> 
     <span class="n">LF_AID_TARGET</span> <span class="o">=</span> <span class="mi">8</span><span class="p">,</span> 
     <span class="n">LF_NAME</span> <span class="o">=</span> <span class="mi">9</span><span class="p">,</span> 
     <span class="n">LF_CHANNEL_ID</span> <span class="o">=</span> <span class="mi">10</span><span class="p">,</span> 
     <span class="n">LF_LOGIN_ID</span> <span class="o">=</span> <span class="mi">13</span><span class="p">,</span> 
     <span class="n">LF_COUNT</span> <span class="o">=</span> <span class="mi">16</span><span class="p">,</span> 
     <span class="n">LF_ROOM_ID</span> <span class="o">=</span> <span class="mi">22</span><span class="p">,</span> 
     <span class="n">LF_STAGE_ID</span> <span class="o">=</span> <span class="mi">23</span><span class="p">,</span> 
     <span class="p">...</span> 
 <span class="p">};</span> 
 </code></pre> 

 <p>넷드론 엔진은 다음과 같이 <u>FILELOG</u> 매크로를 제공합니다.</p> 

 <pre> 
 <code class="cpp syntaxhl"><span class="n">FILELOG</span><span class="p">(</span> 
     <span class="n">LE_ROOM_CREATE</span> 
     <span class="o">&lt;&lt;</span> <span class="n">LF_AID</span> <span class="o">&lt;&lt;</span> <span class="n">rkActor_</span><span class="p">.</span><span class="n">GetAid</span><span class="p">()</span> 
     <span class="o">&lt;&lt;</span> <span class="n">LF_ROOM_ID</span> <span class="o">&lt;&lt;</span> <span class="n">pkRoom</span><span class="o">-&gt;</span><span class="n">GetId</span><span class="p">()</span> 
     <span class="o">&lt;&lt;</span> <span class="n">LF_STAGE_ID</span> <span class="o">&lt;&lt;</span> <span class="n">pkRoom</span><span class="o">-&gt;</span><span class="n">GetStageId</span><span class="p">()</span> 
     <span class="o">&lt;&lt;</span> <span class="n">LF_STRING</span> <span class="o">&lt;&lt;</span> <span class="n">pkRoom</span><span class="o">-&gt;</span><span class="n">GetName</span><span class="p">());</span> 
 </code></pre> 

 <p><u>FILELOG</u> 매크로는 항상 시작 필드에 기록 시간을 남기게 되고 &lt;&lt; 연산자를 <u>,</u> 로 인식합니다.</p> 

 <pre> 
 1452416264,26,7,7,22,3072,23,1,6,enjoy your time 
 1452416267,26,7,7,22,3072,23,1,6,enjoy your time 
 1452416272,26,7,7,22,3072,23,1,6,enjoy your time 

 </pre> 

 <p>어떠신가요?</p> 

 <p>문자열 이벤트, 필드 문자열을 사용할때 보다 매우 작은 크기로 저장됩니다. 온라인 게임 서비스를 운영할 때는 매일같이 상당한 양의 로그를 기록합니다. 즉 디스크 용량 한계, 디스크 IO 속도, 로그 데이터 크기, 로그 기록 위치 등을 고려해야 하며 이를 소홀히 할 경우 심각한 상황들을 초래합니다.</p>