1 **************************************************************************
2 * The following are additional notes on all programs that print a colorized
3 * ("colourised") output, *color*.d.
5 * $Id: ALLcolors_notes.txt 58 2007-10-01 13:36:29Z brendan $
7 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
8 **************************************************************************
10 * The colors aren't working, I see rubbish characters
12 Try using a terminal that supports colors, such as gnome-terminal or dtterm.
14 The following text should test the spectrum of colors for your terminal.
15 Read this using "more" or "cat" (not "less" or "vim") to check if your
16 terminal will print colors, and what they will look like:
18 Color Test String Dark Background
19 ---------------------------------------------------------
20 black
\e[30mcolor test
\e[0m
\e[30;40mcolor test
\e[0m
21 red
\e[31mcolor test
\e[0m
\e[31;40mcolor test
\e[0m
22 green
\e[32mcolor test
\e[0m
\e[32;40mcolor test
\e[0m
23 yellow
\e[33mcolor test
\e[0m
\e[33;40mcolor test
\e[0m
24 blue
\e[34mcolor test
\e[0m
\e[34;40mcolor test
\e[0m
25 magenta
\e[35mcolor test
\e[0m
\e[35;40mcolor test
\e[0m
26 cyan
\e[36mcolor test
\e[0m
\e[36;40mcolor test
\e[0m
27 white
\e[37mcolor test
\e[0m
\e[37;40mcolor test
\e[0m
29 and now for a test of attributes:
32 ---------------------------------------------------------
33 black
\e[1;30mcolor test
\e[0m
\e[2;30mcolor test
\e[0m
34 red
\e[1;31mcolor test
\e[0m
\e[2;31mcolor test
\e[0m
35 green
\e[1;32mcolor test
\e[0m
\e[2;32mcolor test
\e[0m
36 yellow
\e[1;33mcolor test
\e[0m
\e[2;33mcolor test
\e[0m
37 blue
\e[1;34mcolor test
\e[0m
\e[2;34mcolor test
\e[0m
38 magenta
\e[1;35mcolor test
\e[0m
\e[2;35mcolor test
\e[0m
39 cyan
\e[1;36mcolor test
\e[0m
\e[2;36mcolor test
\e[0m
40 white
\e[1;37mcolor test
\e[0m
\e[2;37mcolor test
\e[0m
43 * Why so much green and violet in the toolkit scripts?
45 As DTrace can examine the entire software stack, it is conceivable that
46 your script could print events from many different layers each with their
47 own color. Color scripts in the DTraceToolkit generally start by tracing
48 two layers, with extra layers added by the end user as needed (you). The
51 Software Layer Example Provider Color
52 -------------------------------------------------------
53 Dynamic Language perl violet
54 User Library pid:libperl blue
55 OS Library pid:libc cyan
56 System Calls syscall green
57 Kernel and Drivers fbt red
59 How these colors will look will depend on your terminal software. Useful
60 variations can be made, for example using red/bold for kernel abstraction
61 providers (io, vminfo, ...); and red/faint for raw kernel tracing (fbt).
63 The color examples in this toolkit usually trace the syscall and dynamic
64 language layers, hense the green and violet.
67 * I don't like the choosen terminal colors / your colors suck
69 It should be easy to customize them by tweaking the script. I've tried
70 to use the following convention for declaring colors in D scripts:
74 color_shell = "\033[2;35m"; /* violet, faint */
75 color_line = "\033[1;35m"; /* violet, bold */
76 color_syscall = "\033[2;32m"; /* green, faint */
77 color_off = "\033[0m"; /* default */
80 That way, printf() statements can print these string variables to turn
81 on and off colors, as needed. These strings contain an escape sequence to
82 inform your terminal software to change the output color. Customizations
83 can be made by tweaking the variables; refer to documentation for your
84 terminal software to see what numbers will print what colors.
86 For my terminal (dtterm), the numbers are (from dtterm(5)):
111 * I'd like to use this colored output on a website.
113 The easiest way would be to change the script to output HTML rather than
114 escape sequences. eg:
118 color_shell = "<font color=\"#FFAAFF\">"; /* violet, faint */
119 color_line = "<font color=\"#FF44FF\">"; /* violet, bold */
120 color_syscall = "<font color=\"#44CC44\">"; /* green, faint */
121 color_off = "</font>"; /* default */
124 Other tweaks can be made to either print the output in a <pre> tagged block;
125 or as seperate lines ending in <br> along with changing the font to be