-
Notifications
You must be signed in to change notification settings - Fork 32
Formatters
Your logs can look so much nicer now! The idea is for each cell to show, visually, as much information as possible. Just like one of those nice IDEs we love. For instance, isn't it nice to view the line numbers in a clear fashion, different from the rest of the log? And have the information show as non-intrusive, but still powerful? Like, the selected line, show it just a bit darker, and with a nice arrow on the line itself - nothing else.
That's what Column Formatters do. They take the information in each cell, and make it pretty.
For a given log, you edit all the Custom Formatters at once. I've created a simple syntax, so the process is seamless and quite powerful:
[column_name1]
formatter_name1
property11=value11
property12=value12
...
[column_name2]
formatter_name2
property21=value21
propertyp22=value22
...
The column name
is what the name says - the name of the column:
-
all
means: apply to all columns. An easy way to apply a formatting everywhere -
msg
refers to the Message column -
thread
refers the the Thread column, and so on. Just remember to write it in lowercase
[all]
format
time.format_time=MM/dd HH:mm:ss,fff
[msg]
format
number.color=darkred
regex.expr=(?<=\[).*(?=\])|(?<=\().*(?=\))|(?<=\{).*(?=\})
regex.format=lighter
[level]
picture
pic=info->icons\level\info.png
pic2=error->icons\level\error.png
The Formatters are applied in the order you write them. Most of the time, you don't need to worry about that.
There are times when you do need to clearly specify it. For instance, say you want to write numbers in red. But you also have a regex that transforms some specific numbers into violet. In this case,
- if the regex is run first, then all numbers will be written in red
- if the regex is run last, then your specific numbers will be written in violet
The really cool stuff is that you have instant preview as you specify the Formatters:
- Any mistake you make is shown in red at the bottom
- Anything you do takes effect instantly, so you know if your regexes are correct the instant you write them
- The Preview is from the rows surrounding your currently selected row. This way, if you have some complicated formatting to apply, just go to where that would take effect, do your editing until your formatting suits your needs
- You can resize the 'Edit Column Formatters' window to see a bigger Preview, if you wish
Here are the available Formatters you can use:
-
format
: general formatting: regexes, abbreviations, numbers (see below). Note that you can apply formatting to parts of the text -
cell
: apply some formatting to the whole cell -
picture
: transform information info pretty pictures -
stack_trace
andxml
- not implemented yet. Let me know if you wish some cool formatting of your own.
Any property name that ends in format has an easy and flexible syntax: a/b/c...
It specifies some formatting to be applied to some text.
a
, b
, c
, can be any of:
- bold, italic, underline - make the font bold, italic or underline
- darker, lighter - make the foreground color a bit darker or lighter
- darker-bg, lighter-bg - make the background color a bit darker or lighter
- #color - set the color. If it's the first occurrence, it's the foreground. The second occurrence is the background. To force a color to be background, just add an extra #, like ##color
- font name
- font size
Examples:
-
darker/12/italic
- format the text italic, 12pt, and darker than is (relative to how the normal color would be) -
tahoma/9/red
- make the text red, 9pt, Tahoma -
arial/11/darker/italic
- make the text Arial, 11pt, italic and darker than it would be
When a property relates to the color, here's how you can specify the value:
- known-color - we have some regular known colors, such as red, blue, green, cyan, yellow. They can also be prefixed by
dark
orlight
, such as darkred, lightblue - #rrggbb - specify the color in Hexa, red-green-blue
- ##rrggbb - this specifies the color is meant to be the background
Examples:
red
lightblue
#FF00BB
##CC00BB
Applies all formatting to the whole cell:
-
format=<format>
- applies this format to the whole cell -
selection=<image>
- shows an image on the row that contains the selection -
bookmark=<image>
- shows an image on the row that contains a bookmark -
align=<alignment>
- aligns the text (+ image). Possible values:left
,center
, andright
Example:
format=courier new/#800000/#F0F0F0
align=right
selection=icons\arrow4.png
bookmark=icons\bookmark8.png
Multiline formatting
-
multiline.multi=0 or 1
(defaults to 0). If 1 (on), in case the text contains several lines, they are shown on a single line, so that you see as much info as possible. -
multiline.separator=<separator-char>
- how to separate each line, when showing several lines -
multiline.separator_format=<format>
- how to format the separator, to easily see where each line is -
multiline.alternate_format=<format>
- how to show each alternate line, in order to easily differentiate between them
Example:
multiline.multi=1
multiline.alternate_format=lighter
multiline.separator=|
multiline.separator_format=blue
Full Cell formatting
-
all.format=<format>
- applies formatting to all cell -
all.selection=<image>
- shows an image for the row that contains the selection -
all.bookmark=<image>
- shows an image for the row that contains a bookmark
Time-formatting - this only applies to date/time columns (it's ignored for the other columns)
-
time.show_diff=0 or 1
(default=1). If 1, it will always show difference between this and the previous row, so that you very easily see what changed. This is an awesome way to find out what changes from row to row -
time.format=<format>
- formatting to be applied to the time. -
time.light=<color>
- Only useful whenshow_diff=1
. What color to use for showing what's same as previous time -
time.format_time
- how to show the time, a' la' C#'s custom date/time formatting
Example:
time.format=courier new/blue/bold
time.format_time=MM/dd HH:mm:ss,fff
time.light=#adc7e8
Format numbers
-
number.base=2 or 8 or 10 or 16
(default=10). In what base to show the numbers. -
number.pad=<padding>
- how to pad the numbers (only when base is 10). -
number.color=<color>
- the color for showing the numbers -
number.look_for_hex=1 or 0
(default=1) - if 1, we also look for hexadecimal numbers (in order to print them in a different color)
Example:
number.color=darkred
Alternate background
-
alternate.row_count=<rows>
- how many consecutive rows to paint in a certain color. If 1, paint one row in one color, the other one in the alternate color and so on. If 5, paint 5 rows in one color, the next 5 rows in the alternate color, and so on. -
alternate.color=<color>
- the alternate color
Example:
alternate.row_count=5
alternate.color=#fbfdf9
Regex Formatting
-
regex.expr=<regex_expr>
- the regex_expression to match -
regex.format=<format>
- the format to apply to the regex. Note that at this time (1.8.1) - I only allow color to be specified. -
regex2.expr=<regex_expr>
- same as above -
regex2.format=<format>
- same as above -
regex3.expr=<regex_expr>
- same as above -
regex3.format=<format>
- same as above - ... - you can have as many regexes as you want
Example:
regex.expr=(?<=\[).*(?=\])|(?<=\().*(?=\))|(?<=\{).*(?=\})
regex.format=lighter
regex2.expr=(?<=")(?:\\.|[^"\\])*(?=")|(?<=')(?:\\.|[^'\\])*(?=')
regex2.format=darkviolet
The above will show text in any brackets in a lighter color, and text in quotes in violet.
Abbreviations
Allows you to make text shorter, so that you can see more text. Note that this only applies to the text shown in the Current View. You will always see the full text in the Details pane.
-
abb.find=<regex_to_find>
- the regex to find. You can use named regexes. -
abb.replace=<regex_to_replace_with>
- If you don't specify this, we simple remove the found regex from the text.
- You can apply formatting to the replaced text. Anything between
["
and"]
is formatting to be applied to the text in-between - You can use named regexes for the replaced text.
-
abb2.find=<regex_to_find>
- same as above -
abb2.replace=<regex_to_replace_with>
- same as above -
abb3.find=<regex_to_find>
- same as above -
abb3.replace=<regex_to_replace_with>
- same as above - ... - you can have as many abbreviations as possible
Example 1:
abb.find=\{x=(?<x>\d*),y=(?<y>\d*),width=(?<w>\d*),height=(?<h>\d*)\}
abb.replace=["green"][["red/bold"]${x},["blue/italic"]${y},["violet/bold"]${w}/${h}["green"]]
The above will
- find text like
{x=10,y=20,width=100,height=200}
and replace it with[10,20,100/200]
. - It will extra formatting,
- the
[]
will be shown in green, -
x
is shown in bold/red,y
is shown in blue/italic, -
width
andheight
are shown in bold/violet
- the
Example 2:
abb.find=^.*:(?<name>.*)\.xaml
abb.replace=["tahoma/red"]...["blue"]${name}
The above will find any name ending in .xaml
, and replace with ...
(tahoma/red) + the end part of the name is shown in blue.
Compare a number against one or several values, and based on that, select its color
compare-n.where=before*after
-
compare-n.value=int or double
(default=int). What the number is - integer, or double -
compare-n.compare=value,format-less,format-equal,format-greater
- compares number against value. If less, apply the first formatting. If equal, apply middle formatting. If greater, apply last formatting. -
compare-n.compare2=value,format-less,format-equal,format-greater
- same as above, you can compare the original number against several values -
compare-n.compare3=value,format-less,format-equal,format-greater
- same as above, you can compare the original number against several values - ... - you can compare against as many values as you wish
Example:
compare-n.where=time*ms
compare-n.compare=100,green,yellow,orange
compare-n.compare=200,,,red
compare-n.compare=400,,,bold
This will look for numbers like 'time 93 ms', 'time 352 ms'. Numbers:
- less than 100 are shown in green
- 100 is shown yellow
- between 100-200 are shown in orange
- between 200-400 are shown in red
- higher than 400 are shown in red / bold
This replaces any cell starting with a given text with a given picture:
-
pic=text->image
- if the cell's text starts withtext
(case-insensitive), it will show the given image -
pic2=text2->image2
- same as above -
pic3=text3->image3
- same as above - ... - you can have as many pictures as you wish
-
align=<alignment>
. How to align the picture (left
,right
orcenter
).
Example:
picture
pic=info->icons\level\info.png
pic2=error->icons\level\error.png
pic3=fatal->icons\level\fatal.png
pic4=debug->icons\level\debug.png
pic5=warn->icons\level\warn.png
align=center
- Home
- Introduction - on Codeproject
- Pretty Formatting - on Codeproject
- Filtering Logs - on Codeproject
- Notes - on Codeproject
- Event Logs - on Codeproject
- Support for nlog / log4net
- Filters Syntax
- Snoop Around (1.9+)
- Hotkeys
- Screenshots
- Log Syntax
- Show/Hide Information
- Column Formatting Syntax
- Categories