Categorygithub.com/ujiro99/logcatf
modulepackage
1.1.1
Repository: https://github.com/ujiro99/logcatf.git
Documentation: pkg.go.dev

# README

Logcatf Build Status Coverage Status

A Command line tool for format Android Logcat.

Use like this.

$ adb logcat -v time | logcatf --color

Output: ScreenShot

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:

formatlong ver.
%t%time
%a%tag
%p%priority
%i%pid
%I%tid
%m%message

Other Flags:

Flagdescription
%aleft-align
%8amin-width 8, right-align
%-8amin-width 8, left-align
%8.8awidth 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:

ForegroundBackground
blackdark_gray_black__dark_gray_
redlight_red_red__light_red_
greenlight_green_green__light_green_
yellowlight_yellow_yellow__light_yellow_
bluelight_blue_blue__light_blue_
magentalight_magenta_magenta__light_magenta_
cyanlight_cyan_cyan__light_cyan_
whitelight_gray_white__light_gray_
default_default_
Attributes
boldblink_slow
dimblink_fast
underlineinvert
Reset
reset
reset_bold

Contribution

  1. Fork (https://github.com/ujiro99/logcatf/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create a new Pull Request

Author

ujiro99

# Packages

No description provided by the author

# Functions

No description provided by the author

# Constants

AllFormat will be used if format wasn't specified and to-csv was specified.
DefaultFormat will be used if format wasn't specified.
EUCJP represents encode `euc-jp`.
Exit codes are int values that represent an exit code for a particular error.
Exit codes are int values that represent an exit code for a particular error.
ISO2022JP represents encode `iso-2022-jp`.
Name of this command.
ShiftJIS represents encode `shift-jis`.
UTF8 represents encode `utf-8`.
Windows represents encode `windows`.

# Variables

Message has message strings.

# Structs

CLI is the command line object.
Colorizer enables to print strings colored.
FormatError has error message of parameter.
ParameterError has error message of parameter.

# Interfaces

Executor executes a command if neccesary.
Formatter of logcatItem.

# Type aliases

ColorConfig has configuration for colorize.