120 likes | 203 Views
Colors in the Message Service. ATLAS software workshop March 3 2003 Architecture Session. How Colors are Generated. Only works for xterms (or things that work like xterms, eg kterm, gterm, etc). Uses escape (denoted as ^[ ) sequences: ^[[91;1mRED^[[m RED
E N D
Colors in the Message Service ATLAS software workshop March 3 2003 Architecture Session
How Colors are Generated • Only works for xterms (or things that work like xterms, eg kterm, gterm, etc). • Uses escape (denoted as ^[ ) sequences: • ^[[91;1mRED^[[m RED • Escape sequences can be used to set foreground and background colors, as well as font attributes, such as bold, underlined, italics, and blinking. • Support for italics and blinking not well supported by some versions of xterms. • I will never implement any blinking controls as blinking is evil.
Defaults • By default, no colors are shown, and no escape sequences are inserted into the output stream. This prevents log files from getting cluttered up. • Once colored output is activated, the default is to print all warning messages in yellow, error messages in red, and fatal messages in blue on red. This can be overridden as desired. • The colors of all levels of messages sent to the message service can be individually set. • Specific text can also be colored. fatal messages in blue on red
Usage • To enable colored output, in jobOption: messageSvc.useColors = true; • To set individual colors for the message levels, in the jobOption as vectors of strings: MessageSvc.fatalColorCode = {"blue", "red"}; MessageSvc.errorColorCode = {"white", "red"}; MessageSvc.warningColorCode = {"yellow"}; MessageSvc.infoColorCode = {"cyan"}; MessageSvc.debugColorCode = {""}; MessageSvc.verboseColorCode = {""}; • First color is the foreground, second which is optional, is the background.
Usage • Alternatively, you can specify the xterm escape sequence: MessageSvc.fatalColorCode = { "[94;101;1m"}; MessageSvc.errorColorCode = { "[97;101;1m" }; MessageSvc.warningColorCode = { "[93;1m"}; MessageSvc.infoColorCode = { "[96;4m" }; MessageSvc.debugColorCode = { }; MessageSvc.verboseColorCode = { }; • You have to specify the actual escape sequence you want to use, minus the initial escape character. Color codes are appended at the end of this talk, and in the docs. This also allows you to set the font attribute.
Usage • To set the color of individual text, in your C++ code: • MsgStream::setColor( MSG::Color textColor ); • MsgStream::setColor( MSG::Color foreground, MSG::Color background ); • MsgStream::resetColor(); MsgStream log(msgSvc(),name());log.setColor(MSG::GREEN);log << MSG::INFO << “This is in green. ”;log.setColor(MSG::YELLOW, MSG::BLUE);log << “This is in yellow on blue. ”;log.resetColor();log << “This is back to normal” << endreq; • setColor() sets the bold attribute
Allowed Values • xterms only have a limited (8) range of colors allocated to them. These are: • black MSG::BLACK • red MSG::RED • green MSG::GREEN • yellow MSG::YELLOW • blue MSG::BLUE • purple MSG::PURPLE • cyan MSG::CYAN • white MSG::WHITE • These colors names are recognized by the MsgStream::setColor() command. • Any other string used as a jobOption will result in a your default color in bold.
Example Output • What it looks like
Release Schedule • Will be part of Gaudi v12. • in release 6.1.0
xterm Color Codes • Format: • ^[[xx;zm set foreground color • ^[[xx;yy;zm set foreground and background colors • xx: foreground colors, n=0,7 • 30+n == low intensity, • 40+n == low intensity, reverse video • 90+n == high intensity • 100+n == high intensity, reverse video • yy: background colors, n=0,7 • 40+n == low intensity • 100+n == high intensity • The last character (z) before the “m”, is the font modifier: 1 == bold, 2==normal, 4 == underlined