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:
@@ -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);
|
||||
|
||||
@@ -491,6 +491,7 @@ public:
|
||||
|
||||
// Debugger options
|
||||
static bool EnableDebugger;
|
||||
static bool EnableDebuggerColor;
|
||||
static bool EnableDebuggerServer;
|
||||
static bool EnableDebuggerUsageLog;
|
||||
static int DebuggerServerPort;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ Eval {
|
||||
EnableObjDestructCall = true
|
||||
Debugger {
|
||||
EnableDebugger = true
|
||||
EnableDebuggerColor = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
[22;32mWelcome to HipHop Debugger![0m
|
||||
[22;32mType "help" or "?" for a complete list of commands.
|
||||
[0m
|
||||
[22;32mProgram %sprintThis.php loaded. Type '[r]un' or '[c]ontinue' to go.[0m
|
||||
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
|
||||
[22;32mBreakpoint 1 set on line 5 of printThis.php[0m
|
||||
Breakpoint 1 set on line 5 of printThis.php
|
||||
hphpd> run
|
||||
[22;32mBreakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php[0m
|
||||
[22;37m 4 [0m [22;36mfunction[0m [22;34mmethod[0m() {[0m
|
||||
[22;31;47m 5 [0m [22;31;47m$[0m[22;31;47mother[0m[22;31;47m [0m[22;31;47m=[0m[22;31;47m [0m[22;31;47m$[0m[22;31;47mthis[0m[22;31;47m;[0m[0m
|
||||
[22;37m 6 [0m }[0m
|
||||
[0m
|
||||
Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php
|
||||
4 function method() {
|
||||
5 $other = $this;
|
||||
6 }
|
||||
|
||||
hphpd> print $this
|
||||
[22;36mFoo Object
|
||||
Foo Object
|
||||
(
|
||||
[prop] => "Hello\n"
|
||||
)
|
||||
[0m
|
||||
|
||||
hphpd> continue
|
||||
[22;32mBreakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php[0m
|
||||
[22;37m 4 [0m [22;36mfunction[0m [22;34mmethod[0m() {[0m
|
||||
[22;31;47m 5 [0m [22;31;47m$[0m[22;31;47mother[0m[22;31;47m [0m[22;31;47m=[0m[22;31;47m [0m[22;31;47m$[0m[22;31;47mthis[0m[22;31;47m;[0m[0m
|
||||
[22;37m 6 [0m }[0m
|
||||
[0m
|
||||
Breakpoint 1 reached at Foo::method() on line 5 of %sprintThis.php
|
||||
4 function method() {
|
||||
5 $other = $this;
|
||||
6 }
|
||||
|
||||
hphpd> print $this
|
||||
[22;36mFoo Object
|
||||
Foo Object
|
||||
(
|
||||
[prop] => "Hello\n"
|
||||
[prop2] => "\tThere"
|
||||
)
|
||||
[0m
|
||||
|
||||
hphpd> quit
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário