From bc825c0b667e0a5ffa7a86b2ad3eaf9e677108e4 Mon Sep 17 00:00:00 2001 From: "alexeypa@chromium.org" Date: Thu, 18 Oct 2012 01:59:29 +0000 Subject: Redirect Chromoting Host debug logs to Windows event tracing (ETW) instead of a file on disk. This CL prevents infinite growth of debug.log over time. The debug output is redirected to ETW logging. Sawbuck (http://code.google.com/p/sawbuck/) or standard ETW tools can be used to view the debug output. The debug build still uses "debug.log" (along with ETW) to simplify debugging. The installation registers "Chromoting" provider with Sawbuck and deletes the existing "debug.log" file during both installation and uninstallation. BUG=156135 Review URL: https://chromiumcodereview.appspot.com/11188016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162614 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/host/desktop_process.cc | 17 ++------- remoting/host/installer/win/chromoting.wxs | 34 ++++++++++++++++++ remoting/host/logging.h | 17 +++++++++ remoting/host/logging_posix.cc | 21 +++++++++++ remoting/host/logging_win.cc | 46 +++++++++++++++++++++++++ remoting/host/remoting_me2me_host.cc | 16 ++------- remoting/host/simple_host_process.cc | 15 ++------ remoting/host/win/elevated_controller_module.cc | 13 ++----- remoting/host/win/host_service.cc | 11 ++---- remoting/remoting.gyp | 35 +++++++++++++------ remoting/tools/DEPS | 3 ++ remoting/tools/breakpad_tester_win.cc | 8 ++--- 12 files changed, 157 insertions(+), 79 deletions(-) create mode 100644 remoting/host/logging.h create mode 100644 remoting/host/logging_posix.cc create mode 100644 remoting/host/logging_win.cc create mode 100644 remoting/tools/DEPS (limited to 'remoting') diff --git a/remoting/host/desktop_process.cc b/remoting/host/desktop_process.cc index 77e5410..4a4ab6d 100644 --- a/remoting/host/desktop_process.cc +++ b/remoting/host/desktop_process.cc @@ -10,13 +10,12 @@ #include "base/at_exit.h" #include "base/command_line.h" #include "base/file_path.h" -#include "base/logging.h" #include "base/scoped_native_library.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "base/win/windows_version.h" -#include "remoting/host/branding.h" #include "remoting/host/host_exit_codes.h" +#include "remoting/host/logging.h" #include "remoting/host/usage_stats_consent.h" #if defined(OS_MACOSX) @@ -74,19 +73,7 @@ int main(int argc, char** argv) { // LazyInstance, MessageLoop). base::AtExitManager exit_manager; - // Initialize logging with an appropriate log-file location, and default to - // log to that on Windows, or to standard error output otherwise. - FilePath debug_log = remoting::GetConfigDir(). - Append(FILE_PATH_LITERAL("debug.log")); - InitLogging(debug_log.value().c_str(), -#if defined(OS_WIN) - logging::LOG_ONLY_TO_FILE, -#else - logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, -#endif - logging::DONT_LOCK_LOG_FILE, - logging::APPEND_TO_OLD_LOG_FILE, - logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + remoting::InitHostLogging(); const CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(kHelpSwitchName) || diff --git a/remoting/host/installer/win/chromoting.wxs b/remoting/host/installer/win/chromoting.wxs index 09acada..a7754a0 100644 --- a/remoting/host/installer/win/chromoting.wxs +++ b/remoting/host/installer/win/chromoting.wxs @@ -353,6 +353,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/remoting/host/logging.h b/remoting/host/logging.h new file mode 100644 index 0000000..5b59516 --- /dev/null +++ b/remoting/host/logging.h @@ -0,0 +1,17 @@ +// Copyright (c) 2012 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. + +#ifndef REMOTING_HOST_LOGGING_H_ +#define REMOTING_HOST_LOGGING_H_ + +#include "base/logging.h" + +namespace remoting { + +// Initializes host logging. +extern void InitHostLogging(); + +} // namespace remoting + +#endif // REMOTING_HOST_LOGGING_H_ diff --git a/remoting/host/logging_posix.cc b/remoting/host/logging_posix.cc new file mode 100644 index 0000000..fa6be18 --- /dev/null +++ b/remoting/host/logging_posix.cc @@ -0,0 +1,21 @@ +// Copyright (c) 2012 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 "remoting/host/logging.h" + +#include "base/logging.h" + +namespace remoting { + +void InitHostLogging() { + // Write logs to the system debug log. + logging::InitLogging( + NULL, + logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, + logging::LOCK_LOG_FILE, + logging::DELETE_OLD_LOG_FILE, + logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); +} + +} // namespace remoting diff --git a/remoting/host/logging_win.cc b/remoting/host/logging_win.cc new file mode 100644 index 0000000..0ab6f59 --- /dev/null +++ b/remoting/host/logging_win.cc @@ -0,0 +1,46 @@ +// Copyright (c) 2012 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 "remoting/host/logging.h" + +#include + +#include "base/file_path.h" +#include "base/logging.h" +#include "base/logging_win.h" +#include "remoting/host/branding.h" + +// {2db51ca1-4fd8-4b88-b5a2-fb8606b66b02} +const GUID kRemotingHostLogProvider = + { 0x2db51ca1, 0x4fd8, 0x4b88, + { 0xb5, 0xa2, 0xfb, 0x86, 0x06, 0xb6, 0x6b, 0x02 } }; + +namespace remoting { + +void InitHostLogging() { +#if defined(NDEBUG) + // Write logs to the system debug log in release build. + logging::InitLogging( + NULL, + logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, + logging::LOCK_LOG_FILE, + logging::DELETE_OLD_LOG_FILE, + logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); +#else // !defined(NDEBUG) + // Write logs to a file in debug build. + FilePath debug_log = remoting::GetConfigDir(). + Append(FILE_PATH_LITERAL("debug.log")); + logging::InitLogging( + debug_log.value().c_str(), + logging::LOG_ONLY_TO_FILE, + logging::LOCK_LOG_FILE, + logging::DELETE_OLD_LOG_FILE, + logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); +#endif // !defined(NDEBUG) + + // Enable trace control and transport through event tracing for Windows. + logging::LogEventProvider::Initialize(kRemotingHostLogProvider); +} + +} // namespace remoting diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index b3b9fe0..c502933 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -12,7 +12,6 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/file_util.h" -#include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "base/scoped_native_library.h" @@ -51,6 +50,7 @@ #include "remoting/host/host_user_interface.h" #include "remoting/host/ipc_consts.h" #include "remoting/host/json_host_config.h" +#include "remoting/host/logging.h" #include "remoting/host/log_to_server.h" #include "remoting/host/network_settings.h" #include "remoting/host/policy_hack/policy_watcher.h" @@ -752,19 +752,7 @@ int main(int argc, char** argv) { return 0; } - // Initialize logging with an appropriate log-file location, and default to - // log to that on Windows, or to standard error output otherwise. - FilePath debug_log = remoting::GetConfigDir(). - Append(FILE_PATH_LITERAL("debug.log")); - InitLogging(debug_log.value().c_str(), -#if defined(OS_WIN) - logging::LOG_ONLY_TO_FILE, -#else - logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, -#endif - logging::DONT_LOCK_LOG_FILE, - logging::APPEND_TO_OLD_LOG_FILE, - logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + remoting::InitHostLogging(); #if defined(TOOLKIT_GTK) // Required for any calls into GTK functions, such as the Disconnect and diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index 1b5b658..dd26e4a 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -23,7 +23,6 @@ #include "base/command_line.h" #include "base/environment.h" #include "base/file_path.h" -#include "base/logging.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/string_number_conversions.h" @@ -49,6 +48,7 @@ #include "remoting/host/host_secret.h" #include "remoting/host/it2me_host_user_interface.h" #include "remoting/host/json_host_config.h" +#include "remoting/host/logging.h" #include "remoting/host/log_to_server.h" #include "remoting/host/network_settings.h" #include "remoting/host/register_support_host_request.h" @@ -389,18 +389,7 @@ int main(int argc, char** argv) { base::AtExitManager exit_manager; - // Initialize logging with an appropriate log-file location, and default to - // log to that on Windows, or to standard error output otherwise. - FilePath debug_log(FILE_PATH_LITERAL("debug.log")); - InitLogging(debug_log.value().c_str(), -#if defined(OS_WIN) - logging::LOG_ONLY_TO_FILE, -#else - logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, -#endif - logging::DONT_LOCK_LOG_FILE, - logging::APPEND_TO_OLD_LOG_FILE, - logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + remoting::InitHostLogging(); #if defined(TOOLKIT_GTK) gfx::GtkInitFromCommandLine(*cmd_line); diff --git a/remoting/host/win/elevated_controller_module.cc b/remoting/host/win/elevated_controller_module.cc index 8b57a9e..620901c 100644 --- a/remoting/host/win/elevated_controller_module.cc +++ b/remoting/host/win/elevated_controller_module.cc @@ -8,10 +8,8 @@ #include "base/at_exit.h" #include "base/command_line.h" -#include "base/file_path.h" -#include "base/logging.h" #include "remoting/base/breakpad.h" -#include "remoting/host/branding.h" +#include "remoting/host/logging.h" #include "remoting/host/usage_stats_consent.h" // MIDL-generated declarations. @@ -49,14 +47,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int command) { // FilePath, LazyInstance, MessageLoop). base::AtExitManager exit_manager; - // Write logs to the application profile directory. - FilePath debug_log = remoting::GetConfigDir(). - Append(FILE_PATH_LITERAL("debug.log")); - InitLogging(debug_log.value().c_str(), - logging::LOG_ONLY_TO_FILE, - logging::DONT_LOCK_LOG_FILE, - logging::APPEND_TO_OLD_LOG_FILE, - logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + remoting::InitHostLogging(); return _AtlModule.WinMain(command); } diff --git a/remoting/host/win/host_service.cc b/remoting/host/win/host_service.cc index 5de9c0f..7158ea0 100644 --- a/remoting/host/win/host_service.cc +++ b/remoting/host/win/host_service.cc @@ -17,7 +17,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/file_path.h" -#include "base/logging.h" #include "base/message_loop.h" #include "base/single_thread_task_runner.h" #include "base/stringprintf.h" @@ -29,6 +28,7 @@ #include "remoting/base/scoped_sc_handle_win.h" #include "remoting/base/stoppable.h" #include "remoting/host/branding.h" +#include "remoting/host/logging.h" #if defined(REMOTING_MULTI_PROCESS) #include "remoting/host/daemon_process.h" @@ -486,14 +486,7 @@ int CALLBACK WinMain(HINSTANCE instance, // FilePath, LazyInstance, MessageLoop). base::AtExitManager exit_manager; - // Write logs to the application profile directory. - FilePath debug_log = remoting::GetConfigDir(). - Append(FILE_PATH_LITERAL("debug.log")); - InitLogging(debug_log.value().c_str(), - logging::LOG_ONLY_TO_FILE, - logging::DONT_LOCK_LOG_FILE, - logging::APPEND_TO_OLD_LOG_FILE, - logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + remoting::InitHostLogging(); const CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(kHelpSwitchName) || diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 496a8db..aaaf0ea 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -497,6 +497,7 @@ 'variables': { 'enable_wexit_time_destructors': 1, }, 'dependencies': [ '../base/base.gyp:base', + 'remoting_host_logging', ], 'sources': [ 'tools/breakpad_tester_win.cc', @@ -596,13 +597,12 @@ '../base/base.gyp:base', 'remoting_breakpad', 'remoting_elevated_controller', + 'remoting_host_logging', 'remoting_protocol', 'remoting_version_resources', ], 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/remoting/remoting_controller_version.rc', - 'host/branding.cc', - 'host/branding.h', 'host/pin_hash.cc', 'host/pin_hash.h', 'host/usage_stats_consent.h', @@ -647,13 +647,12 @@ '../net/net.gyp:net', 'remoting_base', 'remoting_breakpad', + 'remoting_host_logging', 'remoting_version_resources', ], 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/remoting/remoting_daemon_version.rc', 'base/scoped_sc_handle_win.h', - 'host/branding.cc', - 'host/branding.h', 'host/chromoting_messages.cc', 'host/chromoting_messages.h', 'host/config_file_watcher.cc', @@ -923,13 +922,12 @@ 'remoting_base', 'remoting_breakpad', 'remoting_host', + 'remoting_host_logging', 'remoting_version_resources', '../base/base.gyp:base', '../ipc/ipc.gyp:ipc', ], 'sources': [ - 'host/branding.cc', - 'host/branding.h', 'host/desktop_process.cc', 'host/desktop_process.h', 'host/host_ui.rc', @@ -1131,16 +1129,15 @@ 'dependencies': [ 'remoting_base', 'remoting_host', - 'remoting_host_setup_base', 'remoting_host_event_logger', + 'remoting_host_logging', + 'remoting_host_setup_base', 'remoting_jingle_glue', '../net/net.gyp:net', '../third_party/npapi/npapi.gyp:npapi', ], 'sources': [ 'base/dispatch_win.h', - 'host/branding.cc', - 'host/branding.h', 'host/host_ui_resource.h', 'host/plugin/host_log_handler.cc', 'host/plugin/host_log_handler.h', @@ -1672,6 +1669,22 @@ }, # end of target 'remoting_host' { + 'target_name': 'remoting_host_logging', + 'type': 'static_library', + 'variables': { 'enable_wexit_time_destructors': 1, }, + 'dependencies': [ + '../base/base.gyp:base', + ], + 'sources': [ + 'host/branding.cc', + 'host/branding.h', + 'host/logging.h', + 'host/logging_posix.cc', + 'host/logging_win.cc', + ], + }, # end of target 'remoting_host_logging' + + { 'target_name': 'remoting_client', 'type': 'static_library', 'variables': { 'enable_wexit_time_destructors': 1, }, @@ -1712,6 +1725,7 @@ 'dependencies': [ 'remoting_base', 'remoting_host', + 'remoting_host_logging', 'remoting_jingle_glue', '../base/base.gyp:base', '../base/base.gyp:base_i18n', @@ -1732,6 +1746,7 @@ 'remoting_breakpad', 'remoting_host', 'remoting_host_event_logger', + 'remoting_host_logging', 'remoting_jingle_glue', '../base/base.gyp:base', '../base/base.gyp:base_i18n', @@ -1743,8 +1758,6 @@ 'VERSION=<(version_full)', ], 'sources': [ - 'host/branding.cc', - 'host/branding.h', 'host/config_file_watcher.cc', 'host/config_file_watcher.h', 'host/curtain_mode.h', diff --git a/remoting/tools/DEPS b/remoting/tools/DEPS new file mode 100644 index 0000000..c3c25f4 --- /dev/null +++ b/remoting/tools/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+remoting/host", +] diff --git a/remoting/tools/breakpad_tester_win.cc b/remoting/tools/breakpad_tester_win.cc index af1a095..b87d878 100644 --- a/remoting/tools/breakpad_tester_win.cc +++ b/remoting/tools/breakpad_tester_win.cc @@ -7,8 +7,8 @@ #include "base/at_exit.h" #include "base/command_line.h" -#include "base/logging.h" #include "base/win/scoped_handle.h" +#include "remoting/host/logging.h" namespace { @@ -38,11 +38,7 @@ int main(int argc, char** argv) { base::AtExitManager exit_manager; - InitLogging(NULL, - logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, - logging::DONT_LOCK_LOG_FILE, - logging::APPEND_TO_OLD_LOG_FILE, - logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + remoting::InitHostLogging(); const CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(kHelpSwitchName) || -- cgit v1.1