Commit afdc3a2b authored by Tatiana Buldina's avatar Tatiana Buldina Committed by Commit Bot

[ChromeDriver] Allow to append log file

By default ChromeDriver creates new log file,
option '--append-log' allows to append log file.

Bug: chromedriver:586
Change-Id: Ibcbcad66a3afbf5bff0fbbf2046a1fc694395290
Reviewed-on: https://chromium-review.googlesource.com/1247027Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Tatiana Buldina <buldina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594523}
parent a0cb4a2c
......@@ -236,15 +236,20 @@ Log::Level WebDriverLog::min_level() const {
bool InitLogging() {
g_start_time = base::TimeTicks::Now().ToInternalValue();
base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
if (cmd_line->HasSwitch("log-path")) {
g_log_level = Log::kInfo;
base::FilePath log_path = cmd_line->GetSwitchValuePath("log-path");
const base::FilePath::CharType* logMode = FILE_PATH_LITERAL("w");
if (cmd_line->HasSwitch("append-log")) {
logMode = FILE_PATH_LITERAL("a");
}
#if defined(OS_WIN)
FILE* redir_stderr = _wfreopen(log_path.value().c_str(), L"w", stderr);
FILE* redir_stderr = _wfreopen(log_path.value().c_str(), logMode, stderr);
#else
FILE* redir_stderr = freopen(log_path.value().c_str(), "w", stderr);
FILE* redir_stderr = freopen(log_path.value().c_str(), logMode, stderr);
#endif
if (!redir_stderr) {
printf("Failed to redirect stderr to log file.\n");
......
......@@ -360,6 +360,8 @@ int main(int argc, char *argv[]) {
"log verbosely (equivalent to --log-level=ALL)",
"silent",
"log nothing (equivalent to --log-level=OFF)",
"append-log",
"append log file instead of rewriting",
"replayable",
"(experimental) log verbosely and don't truncate long "
"strings so that the log can be replayed.",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment