Log_sulac("sdfsdfasf %d",parm1); 이 가능하게 하려면 아래와 같이 수정하면 됨 (이건 VC6.0에서 사용하는 방법임)
void Log_Sulac(const char* format,...)
{
char buffer[4096];
va_list vaList;
va_start(vaList, format);
_vsnprintf(buffer, 4096, format, vaList);
va_end(vaList);
OutputDebugString(buffer);
}
아 그리고 만약 앞에 '[MEDIC]'같은 문자열을 넣고 싶을 경우 아래와 같이 바꾸면 되여
void Log_Sulac(const char* format,...)
{
char buffer[4096];
va_list vaList;
va_start(vaList, format);
_vsnprintf(buffer, 4096, format, vaList);
va_end(vaList);
// OutputDebugString(buffer);
CString str;
str.Format("[MEDIC]%s",buffer);
OutputDebugString(str);
}
밑에도됨..MFC나 C++에서 사용하면 될듯..ㅋㅋ웅왕굳!
LOG_SULAC(("Port %d, Iconnect %d, iDetect %d"), PARM1,PARM2,PARM3);
inline void LOG_SULAC(const char* format, ...)
{
CString str;
str.Format("[Medic] %s", format);
OutputDebugString(str);
}
/* Copyright (c) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef DEBUG_H #define DEBUG_H /** @file debug.h */ #ifndef NDEBUG #include <stdarg.h> #include <stdio.h> /** Output a debug message * * @param format printf-style format string, followed by variables */ static inline void debug(const char *format, ...) { va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); } /** Conditionally output a debug message * * @param condition output only if condition is true * @param format printf-style format string, followed by variables */ static inline void debug(bool condition, const char *format, ...) { if(condition) { va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); } } #else static inline void debug(const char *format, ...) {} static inline void debug(bool condition, const char *format, ...) {} #endif #endif
1. 디버그 뷰 설치
2. 디버그 뷰 실행
3. 디버그 뷰 설정
많은 프로그램들이 디버그 뷰를 사용하다 보니 두서 없이 스트링이 많이 나올때가 있다.
기본적으로 개발이 끝나고 배포 할때는 디버그 스트링 값을 _OFF 상태로 설정해야 하는데,
다른 사용자들을 배려 하지 않는다고나 할까? ㅎ 뭐 어쨋튼,,,
많은 프로그램들이 디버그에 스트링을 뿌리다 보니 보기도 힘들고 하니,,,
필터링을 해야하는데,,,
첨에 많이 해맷다.
DebugView의 도움말에 잘 나와 있긴 하지만,, ,영어라서 ,,ㅎ
단축키로는 CTRL + L 이고 아이콘은 깔데가기 거꾸로 있는 모습이다.
실행하면 필터링 옵션 창이 뜨고
include와 exclude가 있고 highlight가 있다.
include는 나타낼 스트링의 일부를 이야기 하는거고 기본값은 * 이다(모든 스트링이 나타남).
원하는 스트링만 나타낼때는 handsome;wonderful;sometime 뭐 이런 식으로
구분자가 ; (세미콜론) 이다.
하이라이트 사용법은 일단 설정할 색을 고른 다음 filter1, filter2, filter3...
그리고 색에 표현할 스트링을 적어 넣으면 된다.
그럼 그 단어가 포함된 라인은 설정된 색으로 나타난다.
4. 프로그램에서 사용하기
stdafx.h 에 추가
#define _ON (0)
#define _OFF (1)#define D0 _ON ? (VOID)0 : DebugView
inline void DebugView(TCHAR *pszErr, ...)
{
static CString strErr;
va_list ap;
va_start(ap, pszErr);
strErr.FormatV(pszErr, ap);
va_end(ap);OutputDebugString(_T("[프로젝트명] ") + strErr + _T("\n"));
};
함수 내에서 사용하기
int a = 5;
CString str = _T("gg");
D0( _T("Test::create() a=%d str=%s"), a, str );
뭐 요런 식으로 쓰면,,,,
디버그 뷰에는
[1776] [프로젝트명] Test::create() a=3 str=gg
요렇게 나타난다.
DLL에서도 디버그 모드는 돌아가지만,,,,
ActiveX는 디버그 모드에서 돌릴수가 없다.
디버그모드에서 개발할때보다 시간은 더 걸리지만 부득이하게 사용해야 할때가 있다..
그럴때 유용하게 사용하시길...
'Windows 개발' 카테고리의 다른 글
unicode 와 ansi, std::string 과 CString 상호 변경하기 (0) | 2014.11.19 |
---|---|
데이터 형 변환 string to TCHAR* (0) | 2014.11.11 |
tid 구하기 (0) | 2014.10.19 |
dll 분석 (0) | 2014.09.21 |
(WinAPI) 문자열 함수(멀티바이트->유니코드->TCHAR) (0) | 2014.08.09 |