https://github.com/ujiro99/logcatf
A Command line tool for format Android Logcat.
https://github.com/ujiro99/logcatf
adb android cli format-android-logcat golang library logcat
Last synced: over 1 year ago
JSON representation
A Command line tool for format Android Logcat.
- Host: GitHub
- URL: https://github.com/ujiro99/logcatf
- Owner: ujiro99
- License: apache-2.0
- Created: 2016-01-02T16:45:45.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-05T18:27:08.000Z (over 10 years ago)
- Last Synced: 2024-06-21T00:15:24.805Z (about 2 years ago)
- Topics: adb, android, cli, format-android-logcat, golang, library, logcat
- Language: Go
- Homepage:
- Size: 2.07 MB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Logcatf [](https://travis-ci.org/ujiro99/logcatf) [](https://coveralls.io/github/ujiro99/logcatf?branch=master)
A Command line tool for format Android Logcat.
Use like this.
```bash
$ adb logcat -v time | logcatf --color
```
Output:

## Examples
```bash
# 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](https://github.com/ujiro99/logcatf/releases)
or, use `go get`:
```bash
$ go get github.com/ujiro99/logcatf
```
## Basic Usage
```bash
$ 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.
```bash
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.
```
* This function uses [mitchellh/colorstring](https://github.com/mitchellh/colorstring).
* In format string, you can use color tags.
```bash
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 |
| Reset |
|:-----------|
| reset |
| reset_bold |
## Contribution
1. Fork ([https://github.com/ujiro99/logcatf/fork](https://github.com/ujiro99/logcatf/fork))
1. Create a feature branch
1. Commit your changes
1. Rebase your local changes against the master branch
1. Run test suite with the `go test ./...` command and confirm that it passes
1. Run `gofmt -s`
1. Create a new Pull Request
## Author
[ujiro99](https://github.com/ujiro99)