-
[Sublime Text] Log Highlight카테고리 없음 2020. 8. 7. 11:18
https://packagecontrol.io/packages/Log%20Highlight
Log Highlight 는 log 에서 원하는 Error / Warning / 기타 패턴을 Coloring 해주는 Plugin 이다. Error / Warning 등에 있는 File Path 를 Double Click 하면, 해당 파일, 해당 위치로 바로 갈 수 있는 기능도 제공해준다. 주로 Compile 등에서 Error 날 때, System Log 에서 특정 Pattern 을 Highlight 해서 보고 싶을 때 유용하게 사용할 수 있다.
Log Highlight Pattern 은 Customize 가 가능하다. Default Setting 에는 error 가 포함되어 있는 문장을 Highlight 해주게 되어있다. 간단하게 다음을 테스트해보자. test.log 를 다음과 같이 작성하고 저장한다.
Main.cc: In function ‘int main()’: Main.cc:3:31: error: ‘strlen’ was not declared in this scope int a, b, c = strlen("123"); ^ Main.cc:3:15: warning: unused variable ‘c’ [-Wunused-variable] int a, b, c = strlen("123"); ^ Main.cc:4:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d", &a, &b);
Context Menu 로 Log Highlight 를 실행해보자.
Error / Warning 을 Coloring 해주는 모습을 볼 수 있다. 그리고, Main.cc:3:31 같은 File Link 역시 Coloring 해준다. Main.cc:3:31 을 Double Click 하면 빈 Main.cc 가 열리는 것을 볼 수 있는데, 실제로 만들지 않았기 때문이다. 만약에 실제 Compile Log 를 Highlight 한 경우라면 파일이 열리고 해당 위치를 찾아가게 된다. Error / Warning 부분에 Icon 을 볼 수 있는데, 이 역시 Customize 가 가능하다. Error / Warning 뿐만이 아니라 Severity Level 은 User 가 Pattern 을 정해서 더 추가하고 삭제할 수 있다.
파일로된 Log 뿐만이 아니라 Sublime 에서 Build 명령을 실행한 후 나타나는 Build Output Window 에도 적용이 가능하다. 다음을 작성하고 Build (Ctrl+b) 를 실행해보자
#include <stdio.h> int main() { printf("This is testing for Log Highlight\z") return 0; }
다음은 System Log Type Example 의 Screenshot 이다.
Settings 는 다음과 같다.
{ /* Configuration ____________________________________________ */ // enable context menu "context_menu": true, // Auto Highlight for a log file, build window "auto_highlight" : true, // Output panel list for Auto Highlight "auto_highlight_output_panel": ["exec"], // exec = build /* log list _________________________________________________ */ "log_list" : { "example" : // specify name as yours { "type" : "compile", // "compile" - link, bookmark (icon) are usable, "system" - only for highlight "extension" : [ "*.log", ".vcs.log", ".cpp.log", "message*" ], "output.panel" : [ "exec" ], // exec - to apply to build results "use_link" : true, "search_base": { "enable" : true, // false : when using absolute path "ignore_dir" : [""], // hidden folders are ignored as default, like .git, .svn "max_scan_path" : 1000, }, "bookmark" : { "enable" : true, // false : do not display icons too "goto_error" : true, // automatically goto 1st error line }, "severity" : { "error" : { // specify name as yours "enable" : true, "pattern" : [ // [ "begin regex", "end regex" ] or [ "match regex", "" ] // examples [ "^Error-\\[", "^\\s*[\\n]" ], // Error-[ ~ next empty line (multi-line) [ "^{{{LINK}}}?[^\\r\\n]*?(?i)error", "[\\r\\n]" ], // a line including case-insensitive 'error' with or without a link in front of 'error' [ "^\\w+:\\s*\\*E", "[\\r\\n]" ] // ...: *E ... (single line) // <-- remove, change, add more patterns here --> ], "color" : { // ["foreground", "background"] "base" : ["#F92672", ""], // error message "link" : ["#E6DB74", ""], // link in error message "quote" : ["#4F99D3", ""], // quote in error message }, "icon" : "Danish Royalty/error.png", // remove "icon" not to use icon, "dot", "circle" "bookmark" are possible }, "warning" : { // specify name as yours "enable" : true, "pattern" : [ // examples [ "^Warning-\\[", "^\\s*[\\n]" ], [ "^{{{LINK}}}?[^\\r\\n]*?(?i)warning", "[\\r\\n]" ], [ "^\\w+:\\s*\\*W", "[\\r\\n]" ] ], "color" : { "base" : ["#A1B347", ""], "link" : ["#FD971F", ""], "quote" : ["#4F99D3", ""], }, "icon" : "Danish Royalty/warning.png", }, }, "theme": { "foreground" : "#D7D7D7", "caret" : "#F29718", "selection" : "#3A5166", "selectionBorder" : "#181E26", "lineHighlight" : "#283240", } }, // <-- remove, change, add more log list here --> }, }
Log List 에는 example 이란 이름으로 log 의 종류를 구분하는 setting 이 들어가 있으며 User 가 추가해서 다른 종류의 log 를 정의할 수 있다. 각 종류는 extension 을 정의해서 구분할 수 있다. severity 에는 Error / Warning 이 들어가 있는데, User 가 별도로 정의해서 쓸 수 있다. Pattern 은 Regular Expression 을 사용해서 정의한다. Color / Icon 도 바꿔서 쓸 수 있다. User Settting 을 Customize 했다면, Ctrl+shift+p > Log Highlight: Generate Syntax & Theme 을 실행하여야 한다.