0

[fuchsia] Log startup & version for all production components

This INFO log occurs once per instance of these components and thus is
not spammy. Especially for Runners and WebEngine, it can be useful to
confirm that there is not a version mismatch when installing a new
version.

This also ensures that the WebEngine version is logged (by web_instance)
in cases where ContextProvider is never used, such as when only using
the runners to create Contexts.

Bug: 1010222
Change-Id: I3dff5d85df40f50d642bb4960cb4e10e0d8a80fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2863254
Reviewed-by: Wez <wez@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: David Dorwin <ddorwin@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#912493}
This commit is contained in:
David Dorwin
2021-08-17 06:46:20 +00:00
committed by Chromium LUCI CQ
parent e1b1b7345a
commit fa9aef4999
7 changed files with 32 additions and 12 deletions

@ -2259,8 +2259,8 @@ def CheckSpamLogging(input_api, output_api):
r"^courgette[\\/]courgette_minimal_tool\.cc$",
r"^courgette[\\/]courgette_tool\.cc$",
r"^extensions[\\/]renderer[\\/]logging_native_handler\.cc$",
r"^fuchsia[\\/]base[\\/]init_logging.cc$",
r"^fuchsia[\\/]engine[\\/]browser[\\/]frame_impl.cc$",
r"^fuchsia[\\/]engine[\\/]context_provider_main.cc$",
r"^fuchsia[\\/]runners[\\/]common[\\/]web_component.cc$",
r"^headless[\\/]app[\\/]headless_shell\.cc$",
r"^ipc[\\/]ipc_logging\.cc$",

@ -6,6 +6,9 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "components/version_info/version_info.h"
namespace cr_fuchsia {
@ -42,4 +45,15 @@ bool InitLoggingFromCommandLineDefaultingToStderrForTest(
return InitLoggingFromCommandLine(*command_line);
}
void LogComponentStartWithVersion(base::StringPiece component_name) {
std::string version_string =
base::StringPrintf("Starting %s %s", component_name.data(),
version_info::GetVersionNumber().c_str());
#if !defined(OFFICIAL_BUILD)
version_string += " (built at " + version_info::GetLastChange() + ")";
#endif // !defined(OFFICIAL_BUILD)
LOG(INFO) << version_string;
}
} // namespace cr_fuchsia

@ -5,6 +5,8 @@
#ifndef FUCHSIA_BASE_INIT_LOGGING_H_
#define FUCHSIA_BASE_INIT_LOGGING_H_
#include "base/strings/string_piece_forward.h"
namespace base {
class CommandLine;
}
@ -21,6 +23,11 @@ bool InitLoggingFromCommandLine(const base::CommandLine& command_line);
bool InitLoggingFromCommandLineDefaultingToStderrForTest(
base::CommandLine* command_line);
// Emits an INFO log indicating that |component_name| is starting along with the
// version. Call during the startup of a Fuchsia Component (e.g., in main())
// after InitLoggingFromCommandLine() succeeds.
void LogComponentStartWithVersion(base::StringPiece component_name);
} // namespace cr_fuchsia
#endif // FUCHSIA_BASE_INIT_LOGGING_H_

@ -21,6 +21,7 @@
#include "content/public/browser/network_service_instance.h"
#include "content/public/common/content_switches.h"
#include "fuchsia/base/fuchsia_dir_scheme.h"
#include "fuchsia/base/init_logging.h"
#include "fuchsia/engine/browser/frame_impl.h"
#include "fuchsia/engine/browser/navigation_policy_throttle.h"
#include "fuchsia/engine/browser/url_request_rewrite_rules_manager.h"
@ -84,7 +85,10 @@ std::vector<std::string> GetCorsExemptHeaders() {
WebEngineContentBrowserClient::WebEngineContentBrowserClient()
: cors_exempt_headers_(GetCorsExemptHeaders()),
allow_insecure_content_(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAllowRunningInsecureContent)) {}
switches::kAllowRunningInsecureContent)) {
// Logging in this class ensures this is logged once per web_instance.
cr_fuchsia::LogComponentStartWithVersion("WebEngine web_instance");
}
WebEngineContentBrowserClient::~WebEngineContentBrowserClient() = default;

@ -15,7 +15,6 @@
#include "base/message_loop/message_pump_type.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_executor.h"
#include "components/version_info/version_info.h"
#include "fuchsia/base/feedback_registration.h"
#include "fuchsia/base/init_logging.h"
#include "fuchsia/base/inspect.h"
@ -30,14 +29,6 @@ constexpr char kCrashProductName[] = "FuchsiaWebEngine";
constexpr char kComponentUrl[] =
"fuchsia-pkg://fuchsia.com/web_engine#meta/context_provider.cmx";
std::string GetVersionString() {
std::string version_string = version_info::GetVersionNumber();
#if !defined(OFFICIAL_BUILD)
version_string += " (built at " + version_info::GetLastChange() + ")";
#endif // !defined(OFFICIAL_BUILD)
return version_string;
}
} // namespace
int ContextProviderMain() {
@ -51,7 +42,7 @@ int ContextProviderMain() {
return 1;
}
LOG(INFO) << "Starting WebEngine " << GetVersionString();
cr_fuchsia::LogComponentStartWithVersion("WebEngine context_provider");
ContextProviderImpl context_provider;

@ -58,6 +58,8 @@ int main(int argc, char** argv) {
CHECK(cr_fuchsia::InitLoggingFromCommandLine(*command_line))
<< "Failed to initialize logging.";
cr_fuchsia::LogComponentStartWithVersion("cast_runner");
cr_fuchsia::RegisterFuchsiaDirScheme();
sys::OutgoingDirectory* const outgoing_directory =

@ -67,6 +67,8 @@ int main(int argc, char** argv) {
*base::CommandLine::ForCurrentProcess()))
<< "Failed to initialize logging.";
cr_fuchsia::LogComponentStartWithVersion("web_runner");
cr_fuchsia::RegisterFuchsiaDirScheme();
WebContentRunner::GetContextParamsCallback get_context_params_callback =