From c49afd708dbd224e6493337adb4edca021bb22ab Mon Sep 17 00:00:00 2001 From: rxwen Date: Mon, 7 Sep 2015 19:14:30 +0800 Subject: [PATCH 1/2] add -n/--no-color option to output log without color - useful for getting a clean log file when we redirect output to a log file --- pidcat.py | 8 ++++++-- zsh-completion/_pidcat | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pidcat.py b/pidcat.py index b430d6f..2cc0d7c 100755 --- a/pidcat.py +++ b/pidcat.py @@ -27,7 +27,7 @@ import subprocess from subprocess import PIPE -__version__ = '2.0.0' +__version__ = '2.0.1' LOG_LEVELS = 'VDIWEF' LOG_LEVELS_MAP = dict([(LOG_LEVELS[i], i) for i in range(len(LOG_LEVELS))]) @@ -46,6 +46,7 @@ parser.add_argument('-i', '--ignore-tag', dest='ignored_tag', action='append', help='Filter output by ignoring specified tag(s)') parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + __version__, help='Print the version number and exit') parser.add_argument('-a', '--all', dest='all', action='store_true', default=False, help='Print all log messages') +parser.add_argument('-n', '--no-color', dest='no_color', action='store_true', default=False, help='Do not use colorful output') args = parser.parse_args() min_level = LOG_LEVELS_MAP[args.min_level.upper()] @@ -97,7 +98,10 @@ def termcolor(fg=None, bg=None): return '\033[%sm' % ';'.join(codes) if codes else '' def colorize(message, fg=None, bg=None): - return termcolor(fg, bg) + message + RESET + if args.no_color: + return message + else: + return termcolor(fg, bg) + message + RESET def indent_wrap(message): if width == -1: diff --git a/zsh-completion/_pidcat b/zsh-completion/_pidcat index 731d234..dcf9aae 100644 --- a/zsh-completion/_pidcat +++ b/zsh-completion/_pidcat @@ -57,6 +57,7 @@ _pidcat() { '-v[Print the version number and exit]' \ '-l[Minimum level to be displayed]: :_pidcat_log_levels' \ '-a[Print all log messages]' \ + '-n[Do not user colorful output]' \ '--color-gc[Color garbage collection]' \ '--always-display-tags[Always display the tag name]' \ '--current[Filter logcat by current running app]' \ From 9f58fa66cfc590cbdc1491a4c18eea4fd295cb5a Mon Sep 17 00:00:00 2001 From: rxwen Date: Mon, 7 Sep 2015 19:20:35 +0800 Subject: [PATCH 2/2] fix typo --- zsh-completion/_pidcat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh-completion/_pidcat b/zsh-completion/_pidcat index dcf9aae..546faa0 100644 --- a/zsh-completion/_pidcat +++ b/zsh-completion/_pidcat @@ -57,7 +57,7 @@ _pidcat() { '-v[Print the version number and exit]' \ '-l[Minimum level to be displayed]: :_pidcat_log_levels' \ '-a[Print all log messages]' \ - '-n[Do not user colorful output]' \ + '-n[Do not use colorful output]' \ '--color-gc[Color garbage collection]' \ '--always-display-tags[Always display the tag name]' \ '--current[Filter logcat by current running app]' \