diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index cc5f64db3..35ab85c75 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -42,13 +42,13 @@ // way that may cause binary incompatibility with other builds. The universal // hash value will change if any platform is affected whereas the platform hash // values will change only if that particular platform is affected. -#define CEF_API_HASH_UNIVERSAL "7e96d7c2cfd58a4cf45baac9e75433f3cbb67f63" +#define CEF_API_HASH_UNIVERSAL "fa8cc34484fbca804b3b308446b2c144a0936003" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "f3a24a5c20d1cbf169ea25398e9186370b6d8de1" +#define CEF_API_HASH_PLATFORM "c75b851a2b1000f42c9fd47065902d7500d036ec" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "96a030434c6766961380bb76d92dd59c20ffd2ff" +#define CEF_API_HASH_PLATFORM "67b3ee05c5c6243dedd1bcf061fe3c39c11d97e3" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "5db43c0641a7a5638de64c9ab3d8807ddf6c9e9c" +#define CEF_API_HASH_PLATFORM "4da79d99f6eb7c7773e52da9f78a7c66f72c9c6d" #endif #ifdef __cplusplus diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 7f67c963b..f97cb77f7 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -132,6 +132,42 @@ typedef enum { LOGSEVERITY_DISABLE = 99 } cef_log_severity_t; +/// +/// Log items prepended to each log line. +/// +typedef enum { + /// + /// Prepend the default list of items. + /// + LOG_ITEMS_DEFAULT = 0, + + /// + /// Prepend no items. + /// + LOG_ITEMS_NONE = 1, + + /// + /// Prepend the process ID. + /// + LOG_ITEMS_FLAG_PROCESS_ID = 1 << 1, + + /// + /// Prepend the thread ID. + /// + LOG_ITEMS_FLAG_THREAD_ID = 1 << 2, + + /// + /// Prepend the timestamp. + /// + LOG_ITEMS_FLAG_TIME_STAMP = 1 << 3, + + /// + /// Prepend the tickcount. + /// + LOG_ITEMS_FLAG_TICK_COUNT = 1 << 4, + +} cef_log_items_t; + /// /// Represents the state of a setting. /// @@ -336,6 +372,14 @@ typedef struct _cef_settings_t { /// cef_log_severity_t log_severity; + /// + /// The log items prepended to each log line. If not set the default log items + /// will be used. Also configurable using the "log-items" command-line switch + /// with a value of "none" for no log items, or a comma-delimited list of + /// values "pid", "tid", "timestamp" or "tickcount" for custom log items. + /// + cef_log_items_t log_items; + /// /// Custom flags that will be used when initializing the V8 JavaScript engine. /// The consequences of using custom flags may not be well tested. Also diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index ec84b4c75..6d181aa1e 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -408,6 +408,7 @@ struct CefSettingsTraits { cef_string_set(src->log_file.str, src->log_file.length, &target->log_file, copy); target->log_severity = src->log_severity; + target->log_items = src->log_items; cef_string_set(src->javascript_flags.str, src->javascript_flags.length, &target->javascript_flags, copy); diff --git a/libcef/browser/alloy/alloy_content_browser_client.cc b/libcef/browser/alloy/alloy_content_browser_client.cc index 6d58362f7..3ae226ada 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.cc +++ b/libcef/browser/alloy/alloy_content_browser_client.cc @@ -564,6 +564,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches( switches::kMainBundlePath, #endif switches::kLocalesDirPath, + switches::kLogItems, switches::kLogSeverity, switches::kResourcesDirPath, embedder_support::kUserAgent, diff --git a/libcef/common/alloy/alloy_main_delegate.cc b/libcef/common/alloy/alloy_main_delegate.cc index e90d8f192..9b25c2ac0 100644 --- a/libcef/common/alloy/alloy_main_delegate.cc +++ b/libcef/common/alloy/alloy_main_delegate.cc @@ -22,6 +22,7 @@ #include "base/path_service.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/synchronization/waitable_event.h" #include "chrome/browser/browser_process.h" @@ -212,6 +213,35 @@ absl::optional AlloyMainDelegate::BasicStartupComplete() { } } + if (settings_->log_items != LOG_ITEMS_DEFAULT) { + std::string log_items_str; + if (settings_->log_items == LOG_ITEMS_NONE) { + log_items_str = std::string(switches::kLogItems_None); + } else { + std::vector added_items; + if (settings_->log_items & LOG_ITEMS_FLAG_PROCESS_ID) { + added_items.push_back(base::StringPiece(switches::kLogItems_PId)); + } + if (settings_->log_items & LOG_ITEMS_FLAG_THREAD_ID) { + added_items.push_back(base::StringPiece(switches::kLogItems_TId)); + } + if (settings_->log_items & LOG_ITEMS_FLAG_TIME_STAMP) { + added_items.push_back( + base::StringPiece(switches::kLogItems_TimeStamp)); + } + if (settings_->log_items & LOG_ITEMS_FLAG_TICK_COUNT) { + added_items.push_back( + base::StringPiece(switches::kLogItems_TickCount)); + } + if (!added_items.empty()) { + log_items_str = base::JoinString(added_items, ","); + } + } + if (!log_items_str.empty()) { + command_line->AppendSwitchASCII(switches::kLogItems, log_items_str); + } + } + if (settings_->javascript_flags.length > 0) { command_line->AppendSwitchASCII( blink::switches::kJavaScriptFlags, @@ -346,6 +376,42 @@ absl::optional AlloyMainDelegate::BasicStartupComplete() { logging::SetMinLogLevel(log_severity); } + // Customization of items automatically prepended to log lines. + std::string log_items_str = + command_line->GetSwitchValueASCII(switches::kLogItems); + if (!log_items_str.empty()) { + bool enable_log_of_process_id, enable_log_of_thread_id, + enable_log_of_time_stamp, enable_log_of_tick_count; + enable_log_of_process_id = enable_log_of_thread_id = + enable_log_of_time_stamp = enable_log_of_tick_count = false; + + for (const auto& cur_item_to_log : + base::SplitStringPiece(log_items_str, ",", base::TRIM_WHITESPACE, + base::SPLIT_WANT_NONEMPTY)) { + // if "none" mode is present, all items are disabled. + if (base::EqualsCaseInsensitiveASCII(cur_item_to_log, + switches::kLogItems_None)) { + enable_log_of_process_id = enable_log_of_thread_id = + enable_log_of_time_stamp = enable_log_of_tick_count = false; + break; + } else if (base::EqualsCaseInsensitiveASCII(cur_item_to_log, + switches::kLogItems_PId)) { + enable_log_of_process_id = true; + } else if (base::EqualsCaseInsensitiveASCII(cur_item_to_log, + switches::kLogItems_TId)) { + enable_log_of_thread_id = true; + } else if (base::EqualsCaseInsensitiveASCII( + cur_item_to_log, switches::kLogItems_TimeStamp)) { + enable_log_of_time_stamp = true; + } else if (base::EqualsCaseInsensitiveASCII( + cur_item_to_log, switches::kLogItems_TickCount)) { + enable_log_of_tick_count = true; + } + } + logging::SetLogItems(enable_log_of_process_id, enable_log_of_thread_id, + enable_log_of_time_stamp, enable_log_of_tick_count); + } + logging::InitLogging(log_settings); ContentSettingsPattern::SetNonWildcardDomainNonPortSchemes( diff --git a/libcef/common/cef_switches.cc b/libcef/common/cef_switches.cc index a0cb34db3..b1c5a97ea 100644 --- a/libcef/common/cef_switches.cc +++ b/libcef/common/cef_switches.cc @@ -15,6 +15,14 @@ const char kLogSeverity_Error[] = "error"; const char kLogSeverity_Fatal[] = "fatal"; const char kLogSeverity_Disable[] = "disable"; +// Customization of items automatically prepended to log lines. +const char kLogItems[] = "log-items"; +const char kLogItems_None[] = "none"; +const char kLogItems_PId[] = "pid"; +const char kLogItems_TId[] = "tid"; +const char kLogItems_TimeStamp[] = "timestamp"; +const char kLogItems_TickCount[] = "tickcount"; + // Path to resources directory. const char kResourcesDirPath[] = "resources-dir-path"; diff --git a/libcef/common/cef_switches.h b/libcef/common/cef_switches.h index b2748dc85..ecc1a1b9e 100644 --- a/libcef/common/cef_switches.h +++ b/libcef/common/cef_switches.h @@ -19,6 +19,12 @@ extern const char kLogSeverity_Warning[]; extern const char kLogSeverity_Error[]; extern const char kLogSeverity_Fatal[]; extern const char kLogSeverity_Disable[]; +extern const char kLogItems[]; +extern const char kLogItems_None[]; +extern const char kLogItems_PId[]; +extern const char kLogItems_TId[]; +extern const char kLogItems_TimeStamp[]; +extern const char kLogItems_TickCount[]; extern const char kResourcesDirPath[]; extern const char kLocalesDirPath[]; extern const char kDisablePackLoading[];