티스토리 뷰

simple hints

logging - printf debugging

osnux 2015. 6. 24. 16:09

뭐 개발자라면 누구나 다 가장 쉽게 접근하는 debugging 방법은 printf 아닐까 생각한다.

마치 영어 배울 때, 무조건 외우듯이 일단 막고 퍼보는 거다.


platform 관련 기능을 자주 개발하다 보면(아니 어떤 것을 개발하건), 각기 다른 팀이 개발하는 모듈의 log를 자유자재로 원하는 입맛대로 나오게 만들고 싶지만, 10년의 경험 상 그런 건 불가능 할 듯 싶다는 느낌이다.


결국에 돌고 돌아 여전히 fprintf를 사용하고 있으므로, 관련하여 간단하게 작업할 때 필요한 reference page를 정리해 놓고자 한다. 근데 왠지 너무 기초적인 것을 정리하는 건가 싶지만, 생각이 갑자기 안 나서 매번 googling하는 것을 피하는 정도의 수고를 덜기 위함이다.


- fprintf

http://www.cplusplus.com/reference/cstdio/fprintf/

int fprintf ( FILE * stream, const char * format, ... );


fprintf를 쓰면서 주로 stderr로 찍지만, 가끔 file에도 쓰므로 file도 같이 정리해 본다.


- fopen

http://www.cplusplus.com/reference/cstdio/fopen/?kw=fopen

FILE * fopen ( const char * filename, const char * mode );


- printf류의 format 참고

http://www.cplusplus.com/reference/cstdio/printf/

http://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output


- cstring (string.h) API

http://www.cplusplus.com/reference/cstring/


- opendir

http://man7.org/linux/man-pages/man3/opendir.3.html

http://man7.org/linux/man-pages/man3/closedir.3.html

http://man7.org/linux/man-pages/man2/mkdir.2.html

DIR *opendir(const char *name);


- va_list

http://www.cplusplus.com/reference/cstdarg/va_list/?kw=va_list


- __VA_ARGS__

https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html#Variadic-Macros

https://en.wikipedia.org/wiki/Variadic_macro

http://en.cppreference.com/w/cpp/language/variadic_arguments


- 치환으로 보이나 실제는 결합

https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html#Concatenation


요 정도면 늘 필요할 때마다, 간단하게 log문을 작성해서 그때그때 맞게 집어 넣기 편할 듯 싶다.

'simple hints' 카테고리의 다른 글

do {...} while(0) 문장의 사용과 회피  (0) 2016.07.04
eth0 - dhcp에 대해 간과하기 쉬운 것  (0) 2015.07.24
Single UNIX Specification  (0) 2015.06.03
Qt에서 include 시 필요한 package matching  (0) 2015.03.19
서버 setting  (0) 2015.03.14
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함