diff options
Diffstat (limited to 'chrome/test/webdriver/webdriver_logging.cc')
-rw-r--r-- | chrome/test/webdriver/webdriver_logging.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/chrome/test/webdriver/webdriver_logging.cc b/chrome/test/webdriver/webdriver_logging.cc new file mode 100644 index 0000000..2a0b3c5 --- /dev/null +++ b/chrome/test/webdriver/webdriver_logging.cc @@ -0,0 +1,41 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/test/webdriver/webdriver_logging.h" + +#include "base/file_path.h" +#include "base/file_util.h" +#include "base/logging.h" + +namespace { + +// Path to the WebDriver log file. +const FilePath::CharType kLogPath[] = FILE_PATH_LITERAL("chromedriver.log"); + +} // namespace + +namespace webdriver { + +void InitWebDriverLogging(int min_log_level) { + bool success = InitLogging( + kLogPath, + logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, + logging::LOCK_LOG_FILE, + logging::DELETE_OLD_LOG_FILE, + logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + if (!success) { + PLOG(ERROR) << "Unable to initialize logging"; + } + logging::SetLogItems(false, // enable_process_id + false, // enable_thread_id + true, // enable_timestamp + false); // enable_tickcount + logging::SetMinLogLevel(min_log_level); +} + +bool GetLogContents(std::string* log_contents) { + return file_util::ReadFileToString(FilePath(kLogPath), log_contents); +} + +} // namespace webdriver |