Expose a config file option for turning of colorization in hphpd output.

Expected test output for hphpd command line tests is difficult to read when colorization is present. Although there was an internal switch to turn off colorization (for the benefit of API clients), there was no command line option and no config file option to turn off colorization. This diff adds such an option and also fixes a few places where colorization was added regardless of the value of the internal switch.
Esse commit está contido em:
Herman Venter
2013-05-31 14:25:54 -07:00
commit de sgolemon
commit fd977f7091
7 arquivos alterados com 36 adições e 28 exclusões
+2
Ver Arquivo
@@ -436,6 +436,7 @@ std::string RuntimeOption::SandboxDirectoriesRoot;
std::string RuntimeOption::SandboxLogsRoot;
bool RuntimeOption::EnableDebugger = false;
bool RuntimeOption::EnableDebuggerColor = true;
bool RuntimeOption::EnableDebuggerServer = false;
bool RuntimeOption::EnableDebuggerUsageLog = false;
int RuntimeOption::DebuggerServerPort = 8089;
@@ -1173,6 +1174,7 @@ void RuntimeOption::Load(Hdf &config, StringVec *overwrites /* = NULL */,
{
Hdf debugger = eval["Debugger"];
EnableDebugger = debugger["EnableDebugger"].getBool();
EnableDebuggerColor = debugger["EnableDebuggerColor"].getBool(true);
EnableDebuggerServer = debugger["EnableDebuggerServer"].getBool();
EnableDebuggerUsageLog = debugger["EnableDebuggerUsageLog"].getBool();
DebuggerServerPort = debugger["Port"].getUInt16(8089);
+1
Ver Arquivo
@@ -491,6 +491,7 @@ public:
// Debugger options
static bool EnableDebugger;
static bool EnableDebuggerColor;
static bool EnableDebuggerServer;
static bool EnableDebuggerUsageLog;
static int DebuggerServerPort;
+1 -1
Ver Arquivo
@@ -436,7 +436,7 @@ static void append_line_no(StringBuffer &sb, const char *text,
if (*p == '\n') {
++line;
sb.append(begin, p - begin);
sb.append(ANSI_COLOR_END);
if (color) sb.append(ANSI_COLOR_END);
sb.append('\n');
if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
colorLineNo);
+5 -3
Ver Arquivo
@@ -283,7 +283,6 @@ void DebuggerClient::LoadCodeColor(CodeColor index, Hdf hdf,
SmartPtr<Socket> DebuggerClient::Start(const DebuggerClientOptions &options) {
TRACE(2, "DebuggerClient::Start\n");
Debugger::SetTextColors();
SmartPtr<Socket> ret = getStaticDebuggerClient().connectLocal();
getStaticDebuggerClient().start(options);
return ret;
@@ -633,6 +632,9 @@ void DebuggerClient::init(const DebuggerClientOptions &options) {
m_outputBuf.clear();
}
UseColor &= RuntimeOption::EnableDebuggerColor;
if (UseColor) Debugger::SetTextColors();
if (!NoPrompt) {
info("Welcome to HipHop Debugger!");
info("Type \"help\" or \"?\" for a complete list of commands.\n");
@@ -1281,7 +1283,7 @@ bool DebuggerClient::code(CStrRef source, int line1 /*= 0*/, int line2 /*= 0*/,
}
}
if (!sb.empty()) {
print("%s%s", sb.data(), isApiMode() ? "\0" : ANSI_COLOR_END);
print("%s%s", sb.data(), !UseColor ? "\0" : ANSI_COLOR_END);
return true;
}
return false;
@@ -2298,7 +2300,7 @@ void DebuggerClient::loadConfig() {
m_config["UTF8"] = s_use_utf8; // for starter
Hdf color = m_config["Color"];
UseColor = color.getBool(true);
UseColor = color.getBool(true) && RuntimeOption::EnableDebuggerColor;
color = UseColor; // for starter
if (UseColor) {
defineColors(); // (1) no one can overwrite, (2) for starter
+7 -5
Ver Arquivo
@@ -32,12 +32,14 @@ DebuggerServer DebuggerServer::s_debugger_server;
bool DebuggerServer::Start() {
TRACE(2, "DebuggerServer::Start\n");
if (RuntimeOption::EnableDebuggerServer) {
Debugger::SetTextColors();
if (RuntimeOption::EnableDebuggerColor) {
Debugger::SetTextColors();
// Some server commands pre-formatted texts with color for clients. Loading
// a set of default colors for better display.
Hdf hdf;
DebuggerClient::LoadColors(hdf);
// Some server commands pre-formatted texts with color for clients.
// Loading a set of default colors for better display.
Hdf hdf;
DebuggerClient::LoadColors(hdf);
}
return s_debugger_server.start();
}
+1
Ver Arquivo
@@ -5,6 +5,7 @@ Eval {
EnableObjDestructCall = true
Debugger {
EnableDebugger = true
EnableDebuggerColor = false
}
}
+19 -19
Ver Arquivo
@@ -1,32 +1,32 @@
Welcome to HipHop Debugger!
Type "help" or "?" for a complete list of commands.

Program %sprintThis.php loaded. Type '[r]un' or '[c]ontinue' to go.
Welcome to HipHop Debugger!
Type "help" or "?" for a complete list of commands.
Program %sprintThis.php loaded. Type '[r]un' or '[c]ontinue' to go.
hphpd> break printThis.php:5
Breakpoint 1 set on line 5 of printThis.php
Breakpoint 1 set on line 5 of printThis.php
hphpd> run
Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php
 4  function method() {
 5  $other = $this;
 6  }

Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php
4 function method() {
5 $other = $this;
6 }
hphpd> print $this
Foo Object
Foo Object
(
[prop] => "Hello\n"
)

hphpd> continue
Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php
 4  function method() {
 5  $other = $this;
 6  }

Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php
4 function method() {
5 $other = $this;
6 }
hphpd> print $this
Foo Object
Foo Object
(
[prop] => "Hello\n"
[prop2] => "\tThere"
)

hphpd> quit