2011년 12월 31일 토요일

logcat option 및 filter 제대로 셋팅하기

1. cmd 실행
2. chcp 65001 실행
3. adb logcat  option filter 실행

-s              Set default filter to silent.
Like specifying filterspec '*:s'
-f <filename>   Log to file. Default to stdout
-r [<kbytes>]   Rotate log every kbytes. (16 if unspecified). Requires -f
-n <count>      Sets max number of rotated logs to <count>, default 4
-v <format>     Sets the log print format, where <format> is one of:

brief process tag thread raw time threadtime long

-c              clear (flush) the entire log and exit
-d              dump the log and then exit (don't block)
-t <count>      print only the most recent <count> lines (implies -d)
-g              get the size of the log's ring buffer and exit
-b <buffer>     request alternate ring buffer
('main' (default), 'radio', 'events')
-B              output the log in binary
<Filter Spec.....>
filterspecs are a series of
<tag>[:priority]

where <tag> is a log component tag (or * for all) and priority is:
V    Verbose
D    Debug
I    Info
W    Warn
E    Error
F    Fatal
S    Silent (supress all output)

<tag>[:priority] 이부분에 대한 설명을 하자면...

public static final String TAG = "HelloAxlActivity"; <---- 이부분에서 선언한 태크
Log.d(TAG, "hello...."); <--- 이렇게 프로그램에서 사용하죠..

adb logcat HelloAxlActivity 가 되는 거죠...

그런데, 이상하죠.. 온동네 tag들이 다나옵니다. 이거 하라는 데로 했는데... 헐...
한가지가 더 있답니다.
마지막으로 젤 중요한것은요... 저도 정말 알고 싶어 했던거...

adb logcat HelloAxlActivity *:S

뒤에 *:S 로 HelloAxlActivity이후 한칸띈 후 마무리를 해주셔야 비로소 HelloAxlActivity Tag만을 가진 로그가 나옵니다. (이거 버근가?)

암튼, priority는 tag이후에 붙여 주시면 되겠습니다.

adb logcat HelloAxlActivity:I *:S  이렇게요...

이것과 똑같이 option을 이용해서 할 수도 있는데요...

adb logcat -s HelloAxlActivity:I

-s 는 silent로 만드는 option입니다.

위와 같이 하면 중간에
--------- beginning of /dev/log/system
.....
--------- beginning of /dev/log/main

이런식으로 두가지의 logfile의 내용을 한꺼번에 보여주는데요..

이는 옵션을 주어 버퍼를 선택할 수 있습니다.
adb logcat -b main -s HelloAxlActivity:I 이런식으로요..

이상이구요. 질문있으시면 알려주세요.