Skip to content

Commit 5a53cf4

Browse files
authored
Fix log_prefix initialization. (proxy-wasm#124)
Signed-off-by: mathetake <[email protected]>
1 parent 9937669 commit 5a53cf4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

include/proxy-wasm/context.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ struct PluginBase {
5050
std::string_view runtime, std::string_view plugin_configuration, bool fail_open)
5151
: name_(std::string(name)), root_id_(std::string(root_id)), vm_id_(std::string(vm_id)),
5252
runtime_(std::string(runtime)), plugin_configuration_(plugin_configuration),
53-
fail_open_(fail_open), key_(root_id_ + "||" + plugin_configuration_) {}
53+
fail_open_(fail_open), key_(root_id_ + "||" + plugin_configuration_),
54+
log_prefix_(makeLogPrefix()) {}
5455

5556
const std::string name_;
5657
const std::string root_id_;

src/context.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ std::string PluginBase::makeLogPrefix() const {
9696
if (!root_id_.empty()) {
9797
prefix = prefix + " " + std::string(root_id_);
9898
}
99-
if (vm_id_.empty()) {
99+
if (!vm_id_.empty()) {
100100
prefix = prefix + " " + std::string(vm_id_);
101101
}
102102
return prefix;
@@ -134,7 +134,7 @@ std::string ContextBase::makeRootLogPrefix(std::string_view vm_id) const {
134134
if (!root_id_.empty()) {
135135
prefix = prefix + " " + std::string(root_id_);
136136
}
137-
if (vm_id.empty()) {
137+
if (!vm_id.empty()) {
138138
prefix = prefix + " " + std::string(vm_id);
139139
}
140140
return prefix;

0 commit comments

Comments
 (0)