본문 바로가기

IT 번역/Cocos2d-x 메뉴얼[manual] 번역

메시지를 출력하는 방법으로서의 로그 기록하는 방법 | Logging as a way to output messages

앱을 실행하다보면, 가끔은 (솔직히 거의 매번), 어떤 정보를 확인하기 위해서나 디버깅 때문에 콘솔에 메시지들을 보고 싶으실지도 모릅니다. (아니, 거의 100% 필요하지요). 바로 그 기능이 Cocos2d-x에 구현되어 있습니다. log()라는 이름으로 말이지요. 사용법은 다음과 같습니다:

// 단순 문자열
// a simple string
log("This would be outputted to the console");

// 문자열과 변수
// a string and a variable
string s = "My variable";
log("string is %s", s);

// 더블[double]과 변수
// a double and a variable
double dd = 42;
log("double is %f", dd);

// 정수[integer]와 변수
// an integer and a variable
int i = 6;
log("integer is %d", i);

// 플롯[float]과 변수
// a float and a variable
float f = 2.0f;
log("float is %f", f);

// 부울[bool]과 변수
// a bool and a variable
bool b = true;
if (b == true)
    log("bool is true");
else
    log("bool is false");


c++ 사용자들한테는, log() 쓰는거 보다 std::cout을 쓸 수도 있습니다, 원하면요. 근데말입니다, log()가 복잡한 형식의 출력을 하실 때는 더 편하실 거에요. (printf와 cout 중에 뭐가 더 편할까요?)