Package: logcat-color3
logcat-colorA colorful and highly configurable alternative to theadb logcatcommand from
the Android SDK.Note: logcat-color is targetted at OS X and Linux, and does not currently
work in Windows.InstallationInstallation with pip(may require sudo)$[sudo]pipinstalllogcat-color3Installation from Arch Linux User RepositoryPullhttps://aur.archlinux.org/packages/logcat-color3and build it. You can also use prebuilt packages fromarchlinuxcn.Installation using MacPorts$sudoportinstalllogcat-color3Installation from source(requires setuptools, may require sudo)To get the source, simplydownload and extract a release tarball.
Alternatively, you can clone the logcat-color git repository directly:$gitclonehttps://github.com/ya12125/logcat-color3.gitTo install logcat-color from the source directory, run:$pythonsetup.pyinstallExamplesRun and colorifyadb logcat$logcat-colorColorify an old logcat text file you have laying around$logcat-color</path/to/my.logPipe logcat-color to egrep for only the tags you care about$logcat-color-e|egrep'(Tag1|Tag2)'Run logcat-color with acustom profileforfilters, colors, and custom arguments)$logcat-color<profile-name>logcat-color also supports most of the standard adb / logcat arguments, making it a suitable full-time replacement foradb logcat$aliaslogcat=/path/to/logcat-color
$logcat-e
$logcat-d
$logcat-s123456789-bradio-bmainFor command line usage documentation:$logcat-color--helpConfigurationlogcat-color supports a configuration file at$HOME/.logcat-colorThe configuration file is simply a python script, with a few interesting variables
and types available to it.Sample .logcat-color# Full path to adb, default is to look at the environment variable ADB, or# fall back on using "adb" from the system PATHadb="/path/to/adb"# Width of the TAG column, default is 20tag_width=20# Width of the PID column, default is 8pid_width=8# Width of priority (log level) column, default is 3priority_width=3# Whether or not to wrap the message inside a column. Setting this to False# enables easier copy/paste. default is Truewrap=TrueProfilesProfiles live in thelogcat-color configuration file, and
allow logcat-color to customize ADB and logging even further.In short, a single Profile can:Filterbased on arbitrary log data.Use custom adb command line arguments, devices, and log formatsCustomize display and color configuration.A profile is created by simply calling the Profile python constructor with
various named arguments. The only required argument is the Profile'sname:Profile(name="myProfile",...)You can then have logcat-color use this profile by providing it on the command
line. For example:$logcat-colormyProfileTo customize the Profile, simply pass more named arguments to theProfileconstructor. This is a list of all the currently supported named arguments:buffers: A list of logcat buffers to display. By default logcat uses only themainsystem buffer. See theAndroid documentation for logcat buffersfor more information.device: Specifies the device this profile is intended for.
Valid values: True (connect to first available device), or a string with
the serial ID of the device as reported byadb devicesemulator: Similar todevice, but providingTrueconnects to the first
available emulator instead.filters: A list or tuple ofcustom filters.format: The logcat format to use. By default logcat uses thebriefformat.
See theAndroid documentation for logcat formatsfor more information.name: The profile name (required).priorities: A list or tuple of priority levels. logcat-color will exclude
any messages that contain priorities not in this list.
Valid priorities:V(verbose),D(debug),I(info),W(warn),E(error),F(fatal).tags: A list, tuple, or dict of logcat tag names. logcat-color will exclude
any messages that contain tags not in this list. When a dict is used, you can
also assign custom colors to each tag.
Valid tag colors:RED,GREEN,YELLOW,BLUE,MAGENTA,CYAN,WHITEwrap: Whether or not to wrap the message column. Default isTrue.packages: An array containing the packages that you want to filter on.
this will be applied in addition to the filters.Here is an extended example:Profile(name="radio",# Specify a custom devicedevice="device_name",# Enable both radio and main buffers (-b radio -b main)buffers=("radio","main"),# Only pay attention to the RIL and RILC tags, and give them custom colorstags={"RIL":BLUE,"RILC":GREEN},# Only look at these priority levelspriorities=("I","W","E"),# Use threadtime format to get date/time stamps and thread IDsformat="threadtime",# Some custom filtersfilters=(r"My Custom Regex",lambdadata:data["message"]=="Custom filter"),)FiltersFilters allow your profile to have complete control over what log data you
actually see when you run logcat-color.logcat-color will run each line of log output through the list of filters in
your profile. Only when the entire list of filters have accepted the line will
it actually be displayed. This is the equivalent of logically ANDing the results
of each filter. If you require different logic, you should use a custom function
filter, and combine the results of various filters manually.There are currently two different kinds of filters:Regex filtersWhen the regex matches the message portion of a line of logcat output, that line
will then be matched against the next filter. For example:# A negated regex -- exclude any line that matches thisdefnegatedRegex(regex):returnr"^(?!.*"+regex+").*$"Profile(...filters=(negatedRegex(r"debugging: "),r"my custom regex"))Function filtersWhen the function returnsTruefor a line of log output, that line will then
be matched against the next filter. The function will be passed adatadictionary that contains all of the log data:"priority": One of the logcat priorities:V(verbose),D(debug),I(info),W(warn),E(error),F(fatal).
Availability: All logcat formats."message": The log message itself
Availability: All logcat formats."tag": The Tag of this log message.
Availability: All logcat formats exceptthread."pid": The PID of the process that logged the message (in string form).
Availability: All logcat formats excepttag."tid": The ID of the thread that logged the message (in string form).
Availability:thread,threadtime, andlongformats."date": The date of the log message (in string form).
Availability:time,threadtime, andlongformats."time": The time of the log message (in string form).
Availability:time,threadtime, andlongformats.Notice that many of these fields are conditional based on the logcat output
format. Be careful when constructing the logic of function filters, as the field
you are filtering may not exist in the message!An example of a function filter:# only include messages from my app's tagsdefonlyMyApp(data):# Tag isn't available in "thread" format, so use get() to be safe and# return None instead of raising an exceptionreturndata.get("tag")in("MyAppTag1","MyAppTag2")Profile(...filters=(onlyMyApp))Package FiltersWhen you only care about a few (or one) application this will pass all
messages to you by that application.Note: This will require the application's startup message to be accessible
via the current logback trace. The best bet it to start logcat-color then
start the app.An example of package filtersProfile(...packages=["com.android.example"])ScreenshotThanksThanks toJeff Sharkeyfor the original script that logcat-color is based on,coloredlogcat.py.