Logcatf
A Command line tool for format Android Logcat.
Use like this.
$ adb logcat -v time | logcatf --color
Output:
Examples
# show time, pid and message formatted.
$ adb logcat -v time | logcatf "%t %4i %m"
# output to csv format.
$ adb logcat -v threadtime | logcatf --to-csv > logcat.csv
# get screencap on Exception
$ adb logcat -v time | logcatf -o "MY_APP.*Error" -c "adb shell screencap -p /sdcard/a.png"
Install
You can get binary from github release page.
-> Release Page
or, use go get
:
$ go get github.com/ujiro99/logcatf
Basic Usage
$ adb logcat -v time | logcatf "%t, %m"
Available Format:
format |
long ver. |
%t |
%time |
%a |
%tag |
%p |
%priority |
%i |
%pid |
%I |
%tid |
%m |
%message |
Other Flags:
Flag |
description |
%a |
left-align |
%8a |
min-width 8, right-align |
%-8a |
min-width 8, left-align |
%8.8a |
width 8, right-align |
Default Format:
"%t %p %a: %m"
Options
execute commands
You can execute other commands when a keyword matched to Logcat.
-o, --on=ON regex to trigger a COMMAND.
-c, --command=COMMAND COMMAND will be executed on regex matched.
- In COMMAND, you can use parsed logcat value using keyword same as format or environment variables.
ex) -o "MY_APP.*Error" -c "echo %m > error.log"
-o "MY_APP.*Error" -c "echo \${message} > error.log" # linux, mac
-o "MY_APP.*Error" -c "echo %message% > error.log" # Windows
- Command's stdout is redirected to stderr of logcatf.
- You can use multiple -o / -c pairs.
Output CSV
output to CSV format.
--to-csv output to CSV format. double-quote will be escaped.
--encode=ENCODE output character encode. { utf-8 | shift-jis | euc-jp | iso-2022-jp }
- if use on Windows, encode will be used shift-jis.
Color
specify output Color.
--color enable ANSI color. ( defalult = false )
--color-v=COLOR - color for verbose.
--color-d=COLOR - color for debug.
--color-i=COLOR - color for information.
--color-w=COLOR - color for warning.
--color-e=COLOR - color for error.
--color-f=COLOR - color for fatal.
ex) $ adb logcat | logcatf "%t [invert] %a [reset] [_white_] %m" --color --color-i "cyan"
Available Color Tags:
Foreground |
|
Background |
|
black |
dark_gray |
_black_ |
_dark_gray_ |
red |
light_red |
_red_ |
_light_red_ |
green |
light_green |
_green_ |
_light_green_ |
yellow |
light_yellow |
_yellow_ |
_light_yellow_ |
blue |
light_blue |
_blue_ |
_light_blue_ |
magenta |
light_magenta |
_magenta_ |
_light_magenta_ |
cyan |
light_cyan |
_cyan_ |
_light_cyan_ |
white |
light_gray |
_white_ |
_light_gray_ |
default |
|
_default_ |
|
Attributes |
|
bold |
blink_slow |
dim |
blink_fast |
underline |
invert |
Contribution
- Fork (https://github.com/ujiro99/logcatf/fork)
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
go test ./...
command and confirm that it passes
- Run
gofmt -s
- Create a new Pull Request
Author
ujiro99