Hans-Helge
Hans-Helge

Reputation: 1824

How to color keywords with ccze

I use ccze to colorize my log output.

The man page states:

-c, --color KEY=COLOR
    the color of the keyword KEY to COLOR,
    like one would do in one of the configuration files.

I tried several combinations to highlight the keyword "SELECT" but nothing worked. Can someone tell me how to use this option to colorize a keyword in a specific color?

Upvotes: 4

Views: 1821

Answers (2)

Josef Svitak
Josef Svitak

Reputation: 21

Easy to find under source code: ccze-0.2.1/src/ccze-color.c

static ccze_color_keyword_t ccze_color_keyword_map[] = {
  {CCZE_KEYWORD ("default", CCZE_COLOR_DEFAULT, "Default (not colorised)")},
  {CCZE_KEYWORD ("unknown", CCZE_COLOR_UNKNOWN, "Unknown message")},
  {CCZE_KEYWORD ("date", CCZE_COLOR_DATE, "Dates and times")},
  {CCZE_KEYWORD ("host", CCZE_COLOR_HOST, "Host names and IP numbers")},
  {CCZE_KEYWORD ("mac", CCZE_COLOR_MAC, "MAC addresses")},
  {CCZE_KEYWORD ("pid", CCZE_COLOR_PID, "PIDs (Process IDs)")},
  {CCZE_KEYWORD ("pid-sqbr", CCZE_COLOR_PIDB, "Brackets around PIDs")},
  {CCZE_KEYWORD ("get", CCZE_COLOR_HTTP_GET, "HTTP GET")},
  {CCZE_KEYWORD ("post", CCZE_COLOR_HTTP_POST, "HTTP POST")},
  {CCZE_KEYWORD ("head", CCZE_COLOR_HTTP_HEAD, "HTTP HEAD")},
  {CCZE_KEYWORD ("put", CCZE_COLOR_HTTP_PUT, "HTTP PUT")},
  {CCZE_KEYWORD ("connect", CCZE_COLOR_HTTP_CONNECT, "HTTP CONNECT")},
  {CCZE_KEYWORD ("trace", CCZE_COLOR_HTTP_TRACE, "HTTP TRACE")},
  {CCZE_KEYWORD ("httpcodes", CCZE_COLOR_HTTPCODES,
             "HTTP status codes (200, 404, etc)")},
  {CCZE_KEYWORD ("gettime", CCZE_COLOR_GETTIME, "Transfer times")},
  {CCZE_KEYWORD ("getsize", CCZE_COLOR_GETSIZE, "Transfer sizes")},
  {CCZE_KEYWORD ("debug", CCZE_COLOR_DEBUG, "Debug messages")},
  {CCZE_KEYWORD ("error", CCZE_COLOR_ERROR, "Error messages")},
  {CCZE_KEYWORD ("warning", CCZE_COLOR_WARNING, "Warnings")},
  ....
  and much more

Upvotes: 2

andrea689
andrea689

Reputation: 674

You can change only colors of keywords listed on this file:

cat /etc/cczerc

Example:

ccze -c date=yellow

Upvotes: 6

Related Questions