diff --git a/hphp/runtime/base/program_functions.cpp b/hphp/runtime/base/program_functions.cpp index 4619cbc59..9e283c7c8 100644 --- a/hphp/runtime/base/program_functions.cpp +++ b/hphp/runtime/base/program_functions.cpp @@ -583,12 +583,31 @@ static void pagein_self(void) { free(buf); } +/* Sets RuntimeOption::ExecutionMode according + * to commandline options prior to config load + */ +static void set_execution_mode(string mode) { + if (mode == "daemon" || mode == "server" || mode == "replay") { + RuntimeOption::ExecutionMode = "srv"; + Logger::Escape = true; + } else if (mode == "run" || mode == "debug") { + RuntimeOption::ExecutionMode = "cli"; + Logger::Escape = false; + } else if (mode == "translate") { + RuntimeOption::ExecutionMode = ""; + Logger::Escape = false; + } else { + // Undefined mode + always_assert(false); + } +} + static int start_server(const std::string &username) { // Before we start the webserver, make sure the entire // binary is paged into memory. pagein_self(); - RuntimeOption::ExecutionMode = "srv"; + set_execution_mode("server"); HttpRequestHandler::GetAccessLog().init (RuntimeOption::AccessLogDefaultFormat, RuntimeOption::AccessLogs, username); @@ -762,22 +781,6 @@ static void close_server_log_file(int kind) { } } -/* Sets RuntimeOption::ExecutionMode according - * to commandline options prior to config load - */ -static void set_execution_mode(string mode) { - if (mode == "daemon" || mode == "server" || mode == "replay") { - RuntimeOption::ExecutionMode = "srv"; - } else if (mode == "run" || mode == "debug") { - RuntimeOption::ExecutionMode = "cli"; - } else if (mode == "translate") { - RuntimeOption::ExecutionMode = ""; - } else { - // Undefined mode - always_assert(false); - } -} - static int execute_program_impl(int argc, char **argv) { string usage = "Usage:\n\n\t"; usage += argv[0]; @@ -1030,7 +1033,7 @@ static int execute_program_impl(int argc, char **argv) { tempFile = po.file; } - RuntimeOption::ExecutionMode = "cli"; + set_execution_mode("run"); int new_argc; char **new_argv; @@ -1113,7 +1116,7 @@ static int execute_program_impl(int argc, char **argv) { if (po.mode == "replay" && !po.args.empty()) { RuntimeOption::RecordInput = false; - RuntimeOption::ExecutionMode = "srv"; + set_execution_mode("server"); HttpServer server; // so we initialize runtime properly HttpRequestHandler handler; for (int i = 0; i < po.count; i++) { diff --git a/hphp/runtime/base/util/extended_logger.cpp b/hphp/runtime/base/util/extended_logger.cpp index 14b3ebd82..968d8533e 100644 --- a/hphp/runtime/base/util/extended_logger.cpp +++ b/hphp/runtime/base/util/extended_logger.cpp @@ -51,15 +51,7 @@ } \ } \ Logger::Log(Log ## LOGLEVEL, msg, nullptr, true); \ - } \ - void ExtendedLogger::Raw ## LOGLEVEL(const std::string &msg) { \ - if (LogLevel < Log ## LOGLEVEL) return; \ - Logger::Log(Log ## LOGLEVEL, msg, nullptr, false); \ - if (RuntimeOption::InjectedStackTrace && \ - !ExtendedLogger::EnabledByDefault) { \ - Log(Log ## LOGLEVEL, g_vmContext->debugBacktrace()); \ - } \ - } \ + } namespace HPHP { diff --git a/hphp/runtime/base/util/extended_logger.h b/hphp/runtime/base/util/extended_logger.h index c3c645847..58c4c1199 100644 --- a/hphp/runtime/base/util/extended_logger.h +++ b/hphp/runtime/base/util/extended_logger.h @@ -39,12 +39,6 @@ public: static void Info(const char *fmt, ...); static void Verbose(const char *fmt, ...); - // Log messages without escaping. - static void RawError(const std::string &msg); - static void RawWarning(const std::string &msg); - static void RawInfo(const std::string &msg); - static void RawVerbose(const std::string &msg); - // Log additional injected stacktrace. static void Log(LogLevelType level, CArrRef stackTrace, bool escape = true, bool escapeMore = false); diff --git a/hphp/runtime/ext/ext_error.cpp b/hphp/runtime/ext/ext_error.cpp index 98c75c7a0..4875ecb00 100644 --- a/hphp/runtime/ext/ext_error.cpp +++ b/hphp/runtime/ext/ext_error.cpp @@ -17,7 +17,6 @@ #include "hphp/runtime/ext/ext_error.h" #include "hphp/runtime/base/util/exceptions.h" -#include "hphp/runtime/base/runtime_option.h" #include "hphp/runtime/base/util/string_buffer.h" #include "hphp/util/logger.h" @@ -108,17 +107,15 @@ bool f_error_log(CStrRef message, int message_type /* = 0 */, std::string line(message.data(), // Truncate to 512k message.size() > (1<<19) ? (1<<19) : message.size()); - if (RuntimeOption::ServerExecutionMode() || - RuntimeOption::AlwaysEscapeLog) { - Logger::Error(line); - } else { - Logger::RawError(line); + Logger::Error(line); + + if (!RuntimeOption::ServerExecutionMode() && + Logger::UseLogFile && Logger::Output) { // otherwise errors will go to error log without displaying on screen - if (Logger::UseLogFile && Logger::Output) { - std::cerr << line; - } + std::cerr << line; } + return true; } diff --git a/hphp/test/quick/debug_backtrace_multiline.php.expectf b/hphp/test/quick/debug_backtrace_multiline.php.expectf index 196d0df09..8f8171397 100644 --- a/hphp/test/quick/debug_backtrace_multiline.php.expectf +++ b/hphp/test/quick/debug_backtrace_multiline.php.expectf @@ -1 +1,3 @@ -HipHop Fatal error: Uncaught exception 'Exception' with message '55' in %s:55\nStack trace:\n#0 {main} +HipHop Fatal error: Uncaught exception 'Exception' with message '55' in %s/test/quick/debug_backtrace_multiline.php:55 +Stack trace: +#0 {main} diff --git a/hphp/test/quick/exception_destructor_3.php.expectf b/hphp/test/quick/exception_destructor_3.php.expectf index 591201215..49f884798 100644 --- a/hphp/test/quick/exception_destructor_3.php.expectf +++ b/hphp/test/quick/exception_destructor_3.php.expectf @@ -3,5 +3,11 @@ main() starting Calling foo() Calling bar() In ThrowDestruct2::__destruct() -HipHop Warning: Destructor threw an object exception: exception 'Ex2' with message 'Exception leaked out of ThrowDestruct2::__destruct()' in %a on line %d +HipHop Warning: Destructor threw an object exception: exception 'Ex2' with message 'Exception leaked out of ThrowDestruct2::__destruct()' in %s/test/quick/exception_destructor_3.php:23 +Stack trace: +#0 %s/test/quick/exception_destructor_3.php(%d): ThrowDestruct2->__destruct() +#1 %s/test/quick/exception_destructor_3.php(43): bar() +#2 %s/test/quick/exception_destructor_3.php(64): foo() +#3 %s/test/quick/exception_destructor_3.php(76): main() +#4 {main} in %s/test/quick/exception_destructor_3.php on line %d After bar() diff --git a/hphp/test/quick/exception_destructor_4.php.expectf b/hphp/test/quick/exception_destructor_4.php.expectf index 4bacaea40..de0db91ff 100644 --- a/hphp/test/quick/exception_destructor_4.php.expectf +++ b/hphp/test/quick/exception_destructor_4.php.expectf @@ -4,4 +4,9 @@ Calling foo() Calling bar() Throwing in bar() In ExitDestruct::__destruct() -HipHop Fatal error: Uncaught exception 'Exception' with message 'Exception from bar()' in %a \ No newline at end of file +HipHop Fatal error: Uncaught exception 'Exception' with message 'Exception from bar()' in %s/test/quick/exception_destructor_4.php:40 +Stack trace: +#0 %s/test/quick/exception_destructor_4.php(46): bar() +#1 %s/test/quick/exception_destructor_4.php(63): foo() +#2 %s/test/quick/exception_destructor_4.php(75): main() +#3 {main} diff --git a/hphp/test/quick/exception_handler.php.expectf b/hphp/test/quick/exception_handler.php.expectf index 56d09d84e..359e3d08d 100644 --- a/hphp/test/quick/exception_handler.php.expectf +++ b/hphp/test/quick/exception_handler.php.expectf @@ -1,2 +1,8 @@ -HipHop Fatal error: Uncaught exception 'Exception' with message 'throwing first' in %s:9\nStack trace:\n#0 %s(11): main()\n#1 {main} -Exception handler threw an object exception: exception 'Exception' with message 'throwing second' in %s:4\nStack trace:\n#0 (): exn_throw()\n#1 {main} +HipHop Fatal error: Uncaught exception 'Exception' with message 'throwing first' in %s/test/quick/exception_handler.php:9 +Stack trace: +#0 %s/test/quick/exception_handler.php(11): main() +#1 {main} +Exception handler threw an object exception: exception 'Exception' with message 'throwing second' in %s/test/quick/exception_handler.php:4 +Stack trace: +#0 (): exn_throw() +#1 {main} diff --git a/hphp/test/quick/exceptions.php.expectf b/hphp/test/quick/exceptions.php.expectf index dce6619af..401345833 100644 --- a/hphp/test/quick/exceptions.php.expectf +++ b/hphp/test/quick/exceptions.php.expectf @@ -6,23 +6,31 @@ caught 2 before caught caught exception -string(%d) "#0 %s(91): c() -#1 %s(88): b() -#2 %s(99): a() -#3 %s(111): main3() +string(%d) "#0 %s/test/quick/exceptions.php(91): c() +#1 %s/test/quick/exceptions.php(88): b() +#2 %s/test/quick/exceptions.php(99): a() +#3 %s/test/quick/exceptions.php(111): main3() #4 {main}" string(16) "hello, exception" -string(%d) "#0 %s(91): c() -#1 %s(88): b() -#2 %s(99): a() -#3 %s(111): main3() +string(%d) "#0 %s/test/quick/exceptions.php(91): c() +#1 %s/test/quick/exceptions.php(88): b() +#2 %s/test/quick/exceptions.php(99): a() +#3 %s/test/quick/exceptions.php(111): main3() #4 {main}" -Exception from %s:96 -string(%d) "#0 %s(91): c() -#1 %s(88): b() -#2 %s(99): a() -#3 %s(111): main3() +Exception from %s/test/quick/exceptions.php:96 +string(%d) "#0 %s/test/quick/exceptions.php(91): c() +#1 %s/test/quick/exceptions.php(88): b() +#2 %s/test/quick/exceptions.php(99): a() +#3 %s/test/quick/exceptions.php(111): main3() #4 {main}" bar 3 caught 3 -HipHop Fatal error: Uncaught exception 'Ex3' with message '' in %s:21\nStack trace:\n#0 %s(28): bar()\n#1 %s(35): foo2()\n#2 %s(39): foo1()\n#3 (): foo()\n#4 %s(105): array_map()\n#5 %s(111): main3()\n#6 {main} +HipHop Fatal error: Uncaught exception 'Ex3' with message '' in %s/test/quick/exceptions.php:21 +Stack trace: +#0 %s/test/quick/exceptions.php(28): bar() +#1 %s/test/quick/exceptions.php(35): foo2() +#2 %s/test/quick/exceptions.php(39): foo1() +#3 (): foo() +#4 %s/test/quick/exceptions.php(105): array_map() +#5 %s/test/quick/exceptions.php(111): main3() +#6 {main} diff --git a/hphp/test/quick/exceptions4.php.expectf b/hphp/test/quick/exceptions4.php.expectf index 5758383de..dc59f1b55 100644 --- a/hphp/test/quick/exceptions4.php.expectf +++ b/hphp/test/quick/exceptions4.php.expectf @@ -1,2 +1,8 @@ -HipHop Warning: Destructor threw an object exception: exception 'Exception' with message '' in %s on line 21 -HipHop Fatal error: Uncaught exception 'Exception' with message '' in %s:5\nStack trace:\n#0 %s(21): A->__construct()\n#1 {main} +HipHop Warning: Destructor threw an object exception: exception 'Exception' with message '' in %s/test/quick/exceptions4.php:11 +Stack trace: +#0 %s/test/quick/exceptions4.php(21): B->__destruct() +#1 {main} in %s/test/quick/exceptions4.php on line 21 +HipHop Fatal error: Uncaught exception 'Exception' with message '' in %s/test/quick/exceptions4.php:5 +Stack trace: +#0 %s/test/quick/exceptions4.php(21): A->__construct() +#1 {main} diff --git a/hphp/test/quick/method-non-object.php.expectf b/hphp/test/quick/method-non-object.php.expectf index f7234d53a..9334197c7 100644 --- a/hphp/test/quick/method-non-object.php.expectf +++ b/hphp/test/quick/method-non-object.php.expectf @@ -1 +1,3 @@ -HipHop Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function bar() on a non-object' in %s:4\nStack trace:\n#0 {main} +HipHop Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function bar() on a non-object' in %s/test/quick/method-non-object.php:4 +Stack trace: +#0 {main} diff --git a/hphp/test/quick/method-non-object2.php.expectf b/hphp/test/quick/method-non-object2.php.expectf index b5e54da32..2d6c03e89 100644 --- a/hphp/test/quick/method-non-object2.php.expectf +++ b/hphp/test/quick/method-non-object2.php.expectf @@ -1 +1,3 @@ -HipHop Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function bar() on a non-object' in %s:5\nStack trace:\n#0 {main} +HipHop Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function bar() on a non-object' in %s/test/quick/method-non-object2.php:5 +Stack trace: +#0 {main} diff --git a/hphp/test/quick/nested_vm_exceptions.php.expectf b/hphp/test/quick/nested_vm_exceptions.php.expectf index d4767f644..2478dd7cc 100644 --- a/hphp/test/quick/nested_vm_exceptions.php.expectf +++ b/hphp/test/quick/nested_vm_exceptions.php.expectf @@ -1,3 +1,5 @@ Error handler We hit our handler. -HipHop Fatal error: Uncaught exception 'Exception' with message 'Sup' in %s:20\nStack trace:\n#0 {main} +HipHop Fatal error: Uncaught exception 'Exception' with message 'Sup' in %s/test/quick/nested_vm_exceptions.php:20 +Stack trace: +#0 {main} diff --git a/hphp/test/quick/nested_vm_exceptions2.php.expectf b/hphp/test/quick/nested_vm_exceptions2.php.expectf index 989921be9..77e290c00 100644 --- a/hphp/test/quick/nested_vm_exceptions2.php.expectf +++ b/hphp/test/quick/nested_vm_exceptions2.php.expectf @@ -1,3 +1,5 @@ Error handler We hit our handler. -HipHop Fatal error: Uncaught exception 'Exception' with message 'Sup' in %s:26\nStack trace:\n#0 {main} +HipHop Fatal error: Uncaught exception 'Exception' with message 'Sup' in %s/test/quick/nested_vm_exceptions2.php:26 +Stack trace: +#0 {main} diff --git a/hphp/test/quick/not-enough-args.php.expectf b/hphp/test/quick/not-enough-args.php.expectf index 445232e79..5848b61da 100644 --- a/hphp/test/quick/not-enough-args.php.expectf +++ b/hphp/test/quick/not-enough-args.php.expectf @@ -1,8 +1,13 @@ one -HipHop Warning: two() expects exactly 2 parameters, 1 given in %s on line 4 +HipHop Warning: two() expects exactly 2 parameters, 1 given in %s/test/quick/not-enough-args.php on line 4 two -HipHop Warning: three() expects exactly 3 parameters, 1 given in %s on line 5 -HipHop Warning: three() expects exactly 3 parameters, 2 given in %s on line 5 +HipHop Warning: three() expects exactly 3 parameters, 1 given in %s/test/quick/not-enough-args.php on line 5 +HipHop Warning: three() expects exactly 3 parameters, 2 given in %s/test/quick/not-enough-args.php on line 5 three one -HipHop Fatal error: Uncaught exception 'Exception' with message '2, two() expects exactly 2 parameters, 1 given' in %s:8\nStack trace:\n#0 %s(4): error_handler()\n#1 %s(17): two()\n#2 %s(20): main()\n#3 {main} +HipHop Fatal error: Uncaught exception 'Exception' with message '2, two() expects exactly 2 parameters, 1 given' in %s/test/quick/not-enough-args.php:8 +Stack trace: +#0 %s/test/quick/not-enough-args.php(4): error_handler() +#1 %s/test/quick/not-enough-args.php(17): two() +#2 %s/test/quick/not-enough-args.php(20): main() +#3 {main} diff --git a/hphp/test/quick/ns_existing_names_class.php.expectf b/hphp/test/quick/ns_existing_names_class.php.expectf index 30788ab62..5efc5b667 100644 --- a/hphp/test/quick/ns_existing_names_class.php.expectf +++ b/hphp/test/quick/ns_existing_names_class.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Cannot use A\\Cl as Cl because the name is already in use: (Line: 8, Char: 9) in %s on line 8 +HipHop Fatal error: Cannot use A\Cl as Cl because the name is already in use: (Line: 8, Char: 9) in %s on line 8 diff --git a/hphp/test/quick/ns_use_func.php.expectf b/hphp/test/quick/ns_use_func.php.expectf index 40653229d..12702105a 100644 --- a/hphp/test/quick/ns_use_func.php.expectf +++ b/hphp/test/quick/ns_use_func.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Call to undefined function B\\f() in %s on line 7 +HipHop Fatal error: Call to undefined function B\f() in %s on line 7 diff --git a/hphp/test/quick/unwind_backtrace.php.expectf b/hphp/test/quick/unwind_backtrace.php.expectf index ac26f495b..660cef495 100644 --- a/hphp/test/quick/unwind_backtrace.php.expectf +++ b/hphp/test/quick/unwind_backtrace.php.expectf @@ -2,4 +2,9 @@ wat ~something HipHop Notice: Undefined index: object in %s on line 10 NULL -HipHop Fatal error: Uncaught exception 'Exception' with message 'asd' in %s +HipHop Fatal error: Uncaught exception 'Exception' with message 'asd' in %s/hphp/test/quick/unwind_backtrace.php:4 +Stack trace: +#0 %s/hphp/test/quick/unwind_backtrace.php(22): blah() +#1 %s/hphp/test/quick/unwind_backtrace.php(28): Bar->foo() +#2 %s/hphp/test/quick/unwind_backtrace.php(31): main() +#3 {main} diff --git a/hphp/test/slow/object_property/702.php.expectf b/hphp/test/slow/object_property/702.php.expectf index 80fd0dacb..8dc2c631a 100644 --- a/hphp/test/slow/object_property/702.php.expectf +++ b/hphp/test/slow/object_property/702.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Cannot access property started with '\\0' in %s/hphp/test/slow/object_property/702.php on line 4 +HipHop Fatal error: Cannot access property started with '\0' in %s/hphp/test/slow/object_property/702.php on line 4 diff --git a/hphp/test/slow/object_property/704.php.expectf b/hphp/test/slow/object_property/704.php.expectf index 792f92605..732d57399 100644 --- a/hphp/test/slow/object_property/704.php.expectf +++ b/hphp/test/slow/object_property/704.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Cannot access property started with '\\0' in %s/hphp/test/slow/object_property/704.php on line 4 +HipHop Fatal error: Cannot access property started with '\0' in %s/hphp/test/slow/object_property/704.php on line 4 diff --git a/hphp/test/slow/object_property/706.php.expectf b/hphp/test/slow/object_property/706.php.expectf index 2675090ca..56ac49033 100644 --- a/hphp/test/slow/object_property/706.php.expectf +++ b/hphp/test/slow/object_property/706.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Cannot access property started with '\\0' in %s/hphp/test/slow/object_property/706.php on line 4 +HipHop Fatal error: Cannot access property started with '\0' in %s/hphp/test/slow/object_property/706.php on line 4 diff --git a/hphp/test/slow/object_property/708.php.expectf b/hphp/test/slow/object_property/708.php.expectf index 6fe00262e..f485df61b 100644 --- a/hphp/test/slow/object_property/708.php.expectf +++ b/hphp/test/slow/object_property/708.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Cannot access property started with '\\0' in %s/hphp/test/slow/object_property/708.php on line 4 +HipHop Fatal error: Cannot access property started with '\0' in %s/hphp/test/slow/object_property/708.php on line 4 diff --git a/hphp/test/slow/object_property/710.php.expectf b/hphp/test/slow/object_property/710.php.expectf index bc90aadcf..fc35f7c6a 100644 --- a/hphp/test/slow/object_property/710.php.expectf +++ b/hphp/test/slow/object_property/710.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Cannot access property started with '\\0' in %s/hphp/test/slow/object_property/710.php on line 4 +HipHop Fatal error: Cannot access property started with '\0' in %s/hphp/test/slow/object_property/710.php on line 4 diff --git a/hphp/test/slow/object_property/712.php.expectf b/hphp/test/slow/object_property/712.php.expectf index f21c1d805..b1c7c3682 100644 --- a/hphp/test/slow/object_property/712.php.expectf +++ b/hphp/test/slow/object_property/712.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Cannot access property started with '\\0' in %s/hphp/test/slow/object_property/712.php on line 4 +HipHop Fatal error: Cannot access property started with '\0' in %s/hphp/test/slow/object_property/712.php on line 4 diff --git a/hphp/test/slow/object_property/714.php.expectf b/hphp/test/slow/object_property/714.php.expectf index 7feb6e360..0bd4e55fd 100644 --- a/hphp/test/slow/object_property/714.php.expectf +++ b/hphp/test/slow/object_property/714.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Cannot access property started with '\\0' in %s/hphp/test/slow/object_property/714.php on line 4 +HipHop Fatal error: Cannot access property started with '\0' in %s/hphp/test/slow/object_property/714.php on line 4 diff --git a/hphp/test/slow/object_property/716.php.expectf b/hphp/test/slow/object_property/716.php.expectf index 2111a89c0..01bebc36a 100644 --- a/hphp/test/slow/object_property/716.php.expectf +++ b/hphp/test/slow/object_property/716.php.expectf @@ -1 +1 @@ -HipHop Fatal error: Cannot access property started with '\\0' in %s/hphp/test/slow/object_property/716.php on line 4 +HipHop Fatal error: Cannot access property started with '\0' in %s/hphp/test/slow/object_property/716.php on line 4 diff --git a/hphp/test/zend/good/ext-pdo_mysql/bug_37445.php b/hphp/test/zend/bad/ext-pdo_mysql/bug_37445.php similarity index 100% rename from hphp/test/zend/good/ext-pdo_mysql/bug_37445.php rename to hphp/test/zend/bad/ext-pdo_mysql/bug_37445.php diff --git a/hphp/test/zend/good/ext-pdo_mysql/bug_37445.php.expectf b/hphp/test/zend/bad/ext-pdo_mysql/bug_37445.php.expectf similarity index 100% rename from hphp/test/zend/good/ext-pdo_mysql/bug_37445.php.expectf rename to hphp/test/zend/bad/ext-pdo_mysql/bug_37445.php.expectf diff --git a/hphp/tools/out2expectf.py b/hphp/tools/out2expectf.py new file mode 100755 index 000000000..63b883780 --- /dev/null +++ b/hphp/tools/out2expectf.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +import re +import sys + +for test in sys.argv[1:]: + if not test.endswith('.php'): + print ("%s doesn\'t end in .php. All tests should" % test) + sys.exit(1) + + data = file(test + '.out').read() + data = re.sub('/data[^ ]*/hphp', '%s', data) + file(test + '.expectf', 'w').write(data) + + print ('Copied %s.out to %s.expectf' % (test, test)) diff --git a/hphp/util/logger.cpp b/hphp/util/logger.cpp index f6a7c6a2e..a4324e18a 100644 --- a/hphp/util/logger.cpp +++ b/hphp/util/logger.cpp @@ -23,7 +23,7 @@ #include "hphp/util/text_color.h" #include -#define IMPLEMENT_LOGLEVEL(LOGLEVEL) \ +#define IMPLEMENT_LOGLEVEL(LOGLEVEL) \ void Logger::LOGLEVEL(const char *fmt, ...) { \ if (LogLevel < Log ## LOGLEVEL) return; \ va_list ap; va_start(ap, fmt); \ @@ -32,12 +32,8 @@ } \ void Logger::LOGLEVEL(const std::string &msg) { \ if (LogLevel < Log ## LOGLEVEL) return; \ - Log(Log ## LOGLEVEL, msg, nullptr); \ - } \ - void Logger::Raw ## LOGLEVEL(const std::string &msg) { \ - if (LogLevel < Log ## LOGLEVEL) return; \ - Log(Log ## LOGLEVEL, msg, nullptr, false); \ - } \ + Log(Log ## LOGLEVEL, msg, nullptr); \ + } namespace HPHP { @@ -64,6 +60,7 @@ bool Logger::LogHeader = false; bool Logger::LogNativeStackTrace = true; std::string Logger::ExtraHeader; int Logger::MaxMessagesPerRequest = -1; +bool Logger::Escape = true; IMPLEMENT_THREAD_LOCAL(Logger::ThreadData, Logger::s_threadData); Logger *Logger::s_logger = new Logger(); @@ -117,7 +114,7 @@ void Logger::ResetRequestCount() { void Logger::Log(LogLevelType level, const std::string &msg, const StackTrace *stackTrace, - bool escape /* = true */, bool escapeMore /* = false */) { + bool escape /* = false */, bool escapeMore /* = false */) { s_logger->log(level, msg, stackTrace, escape, escapeMore); } @@ -137,8 +134,13 @@ int Logger::GetSyslogLevel(LogLevelType level) { void Logger::log(LogLevelType level, const std::string &msg, const StackTrace *stackTrace, - bool escape /* = true */, bool escapeMore /* = false */) { + bool escape /* = false */, bool escapeMore /* = false */) { + + if (Logger::Escape) { + escape = true; + } assert(!escapeMore || escape); + ThreadData *threadData = s_threadData.get(); if (++threadData->message > MaxMessagesPerRequest && MaxMessagesPerRequest >= 0) { diff --git a/hphp/util/logger.h b/hphp/util/logger.h index 22e5680f6..eba3d6dc5 100644 --- a/hphp/util/logger.h +++ b/hphp/util/logger.h @@ -77,6 +77,7 @@ public: static bool LogNativeStackTrace; static std::string ExtraHeader; static int MaxMessagesPerRequest; + static bool Escape; static void Error(const std::string &msg); static void Warning(const std::string &msg); @@ -88,11 +89,6 @@ public: static void Info(const char *fmt, ...); static void Verbose(const char *fmt, ...); - // log messages without escaping - static void RawError(const std::string &msg); - static void RawWarning(const std::string &msg); - static void RawInfo(const std::string &msg); - static void RawVerbose(const std::string &msg); static void Log(LogLevelType level, const char *type, const Exception &e, const char *file = nullptr, int line = 0); static void OnNewRequest(); @@ -138,7 +134,7 @@ protected: static void LogEscapeMore(LogLevelType level, const char *fmt, va_list ap); static void Log(LogLevelType level, const std::string &msg, const StackTrace *stackTrace, - bool escape = true, bool escapeMore = false); + bool escape = false, bool escapeMore = false); static inline bool IsEnabled() { return Logger::UseLogFile || Logger::UseSyslog; @@ -154,7 +150,7 @@ protected: const char *file = nullptr, int line = 0); virtual void log(LogLevelType level, const std::string &msg, const StackTrace *stackTrace, - bool escape = true, bool escapeMore = false); + bool escape = false, bool escapeMore = false); /** * What needs to be print for each line of logging. Currently it's