메뉴 건너뛰기

조회 수 1444 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

이전글 : https://auto.ddart.net/xe/free/1485

에서 AutoHotkey 환경설정을 완료한 후

 

개발시 Console Log 방법과

비쥬얼스튜디오처럼 출력윈도우에서 함수나 메세지 trace 로그 출력을 클릭하면 곧바로 해당 파일 소스라인을 찾아가게 하는 설정방법에 대한 예제입니다.

 

많은 include 라이브러리 헤더파일, 클래스, 함수를 사용하는 프로젝트에서

이 기능하나로 코딩과 디버깅 효율을 크게 향상시킬수 있습니다.

 

 

환경설정 :

Notepad++프로그램->플러그인->NppExec->Console output filters 에서
아래와 같이 설정(색깔, 폰트스타일지정가능. 전 그냥 U에만 체크했음)

 

consolefileters.jpg

 

예제파일(아래 다운로드 링크 있음) 중 exmaple.ahk를 notepad++에서 열어 F6으로 실행하면
아래처럼 콘솔출력이 됩니다. (console 폰트설정은 맑은 고딕)

 

example.jpg

 

 

이때 필터설정에서 지정한 출력포맷은 밑줄이 그어지는데

아래처럼 원하는 라인을 더블클릭시 해당 파일의 라인으로 곧바로 이동해서 볼수 있습니다.

traceclick.jpg

 

 

 

 

예제소스코드 다운로드 : trace_example.zip

 

 

1. 콘솔 출력함수 예제 (trace_example\lib\log.ahk)

 

;함수나 오류 메세지 추적 로그
TRACE(file, line, msg)
{
    msg := "> " file ":" line ":" msg  "`n"
    FileAppend, %msg%, *, UTF-8
}
; 일반 메세지 로그
LogMessage(ByRef msg)
{
    FormatTime, TimeString, , hh:mm:ss
    FileAppend [%TimeString%] %msg% `n, *, UTF-8
}

 

2. 함수에서 Trace 예제 (trace_example\lib\myfunc.ahk)

 

#include <log>
MyFunction()
{
    TRACE(A_LineFile, A_LineNumber, A_Thisfunc)
    TRACE(A_LineFile, A_LineNumber, "에러,경고등 메세지")
    LogMessage("Hello!")
}

 

3. 클래스에서 Trace 예제 (trace_example\lib\myclass.ahk)

 

#include <log>
class CMyClass
{
   __New()
   {
      TRACE(A_LineFile, A_LineNumber, A_Thisfunc)
   }
   __Delete()
   {
      TRACE(A_LineFile, A_LineNumber, A_Thisfunc)
   }
   Method()
   {
      TRACE(A_LineFile, A_LineNumber, A_Thisfunc)
      LogMessage("Hi!")
   }
}

 

4. 예제 실행 프로그램 (trace_example\example.ahk)

 

#SingleInstance Force
#include <myclass>
#include <myfunc>

MyFunction()
obj := new CMyClass()
obj.Method()
 

 

 

* 오토핫키에서 c/c++ 처럼 전처리 define 구문을 쓸수 있다면

매번 TRACE(A_LineFile, A_LineNumber, A_Thisfunc) 와 같이 길게 타이핑할게 아니라

그냥 TRACE(msg) 처럼 쉬운 형태로 입력이 가능했겠지만 불행히도 autohotkey 개발자가 전처리기능의 필요성엔 공감하지만
autohotkey를 이용해 직접 전처리기를 만들어쓰라고 아주 오래전에 말한 후로 지원소식이 없는것 같습니다.

만드는거야 가능하지만 그걸 컴파일러에서 지원안하면 매번 모든 코드에 preprocessing 하고 실행해야하는...

귀찮지만 복붙에 익숙해질 수 밖에 없네요.

 

 

 

 


List of Articles
번호 제목 글쓴이 날짜 조회 수
6 ECMAScript encodeURI/decodeURI, escape/unescape function spec implementations in autohotkey v1, v2 file ddart 2023.04.16 1237
5 Autohotkey WinAPI Common Controls Example file ddart 2021.01.22 2869
4 Autohotkey MDI Application Example file ddart 2020.12.27 1376
3 WebView2 example for Autohotkey v2, v1 6 file ddart 2020.12.13 1975
» Notepad++에서 콘솔출력과 소스 연동하기 file ddart 2020.11.14 1444
1 Notepad++에서 Autohotkey 개발환경 만들기 2 file ddart 2020.11.12 3337
Board Pagination Prev 1 Next
/ 1