| 1 |
What is clog? |
| 2 |
============= |
| 3 |
|
| 4 |
Clog is a filter that colorizes log files. Have you ever done something like |
| 5 |
this: |
| 6 |
|
| 7 |
$ tail -f /var/log/something.log |
| 8 |
|
| 9 |
and left that running in a terminal, while you debug or run some program? Were |
| 10 |
you able to spot important information as it scrolled by? Depending on the |
| 11 |
volume of data scrolling by, it can be difficult to spot important information. |
| 12 |
|
| 13 |
Clog is a filter, that you run like this: |
| 14 |
|
| 15 |
$ tail -f /var/log/something.log | clog something |
| 16 |
|
| 17 |
The 'something' argument to clog is a section, which refers to a section in |
| 18 |
~/.clogrc with a distinct set of rules. Those rules list patterns to look for, |
| 19 |
and actions to take when the pattern is matched by a line. A typical example |
| 20 |
might be that you want to highlight any line that contains the pattern 'severe'. |
| 21 |
This entry in ~/clogrc achieves this: |
| 22 |
|
| 23 |
something rule /severe/ --> bold line |
| 24 |
|
| 25 |
This rule is in the 'something' section, the pattern is 'severe', and the action |
| 26 |
taken is to embolden the whole line. Pattern 'severe' should probably be more |
| 27 |
restrictive, because it will also match words like 'persevered', but that is |
| 28 |
optional. |
| 29 |
|
| 30 |
Any color can be used, in both the 16- and 256-color space. Some examples are: |
| 31 |
|
| 32 |
bold |
| 33 |
underline |
| 34 |
bold blue |
| 35 |
underline on green |
| 36 |
black on white |
| 37 |
bold red on bright white |
| 38 |
rgb200 on grey4 |
| 39 |
|
| 40 |
Instead of coloring the whole line, specifying 'match' instead will only color |
| 41 |
the parts of the line that match. |
| 42 |
|
| 43 |
The format of the rules is: |
| 44 |
|
| 45 |
<section> rule /<pattern>/ --> <color> <action> |
| 46 |
|
| 47 |
The section is simply a way to allow multiple rules sets, so that one .clogrc |
| 48 |
file can serve multiple uses. The pattern is any supported Standard C Library |
| 49 |
regular expression. Action must be one of 'line', 'match', 'suppress' or |
| 50 |
'blank'. |
| 51 |
|
| 52 |
Rules are processed in order, from top to bottom. This means that a rule defined |
| 53 |
lower in the rc file gets to apply it's color later, and therefore 'on top of' |
| 54 |
that of an earlier rule. |
| 55 |
|
| 56 |
Note that there is a default section, called 'default'. Putting rules in the |
| 57 |
default section means that no section need be specified on the command line. |
| 58 |
Multiple sections may be specified, and the rules are combined. |
| 59 |
|
| 60 |
--- |