diff --git a/include/proxy-wasm/context.h b/include/proxy-wasm/context.h index 51d7dbbde..bf770a7bf 100644 --- a/include/proxy-wasm/context.h +++ b/include/proxy-wasm/context.h @@ -50,7 +50,8 @@ struct PluginBase { std::string_view runtime, std::string_view plugin_configuration, bool fail_open) : name_(std::string(name)), root_id_(std::string(root_id)), vm_id_(std::string(vm_id)), runtime_(std::string(runtime)), plugin_configuration_(plugin_configuration), - fail_open_(fail_open), key_(root_id_ + "||" + plugin_configuration_) {} + fail_open_(fail_open), key_(root_id_ + "||" + plugin_configuration_), + log_prefix_(makeLogPrefix()) {} const std::string name_; const std::string root_id_; diff --git a/src/context.cc b/src/context.cc index 28d5c2ad5..f00442320 100644 --- a/src/context.cc +++ b/src/context.cc @@ -96,7 +96,7 @@ std::string PluginBase::makeLogPrefix() const { if (!root_id_.empty()) { prefix = prefix + " " + std::string(root_id_); } - if (vm_id_.empty()) { + if (!vm_id_.empty()) { prefix = prefix + " " + std::string(vm_id_); } return prefix; @@ -134,7 +134,7 @@ std::string ContextBase::makeRootLogPrefix(std::string_view vm_id) const { if (!root_id_.empty()) { prefix = prefix + " " + std::string(root_id_); } - if (vm_id.empty()) { + if (!vm_id.empty()) { prefix = prefix + " " + std::string(vm_id); } return prefix;