Skip to content

Commit 463603d

Browse files
authored
Fix issue with logging on root contexts. (proxy-wasm#7)
* Fix issue with logging on root contexts.
1 parent 462e0fb commit 463603d

File tree

6 files changed

+69
-8
lines changed

6 files changed

+69
-8
lines changed

BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ cc_test(
5858
deps = [
5959
":include14",
6060
"@com_google_absl//absl/base",
61-
"@com_google_absl//absl/strings:strings",
61+
"@com_google_absl//absl/strings",
6262
"@com_google_absl//absl/types:optional",
6363
"@com_google_googletest//:gtest",
6464
"@com_google_googletest//:gtest_main",
@@ -72,7 +72,7 @@ cc_test(
7272
deps = [
7373
":include14",
7474
"@com_google_absl//absl/base",
75-
"@com_google_absl//absl/strings:strings",
75+
"@com_google_absl//absl/strings",
7676
"@com_google_absl//absl/types:optional",
7777
"@com_google_googletest//:gtest",
7878
"@com_google_googletest//:gtest_main",

context_test.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
#include "include/proxy-wasm/context.h"
216

317
#include "gtest/gtest.h"

include/proxy-wasm/context.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ class ContextBase {
9292

9393
WasmBase *wasm() const { return wasm_; }
9494
uint32_t id() const { return id_; }
95-
bool isVmContext() { return id_ == 0; }
96-
bool isRootContext() { return root_context_id_ == 0; }
95+
bool isVmContext() const { return id_ == 0; }
96+
bool isRootContext() const { return root_context_id_ == 0; }
9797
ContextBase *root_context() { return root_context_; }
98-
string_view root_id() const { return plugin_->root_id_; }
99-
string_view log_prefix() const { return plugin_->log_prefix(); }
98+
string_view root_id() const { return isRootContext() ? root_id_ : plugin_->root_id_; }
99+
string_view log_prefix() const {
100+
return isRootContext() ? root_log_prefix_ : plugin_->log_prefix();
101+
}
100102
WasmVm *wasmVm() const;
101103

102104
// Called before deleting the context.

src/base64.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
// Public Domain: https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Original source Public Domain:
16+
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
217
#include "base64.h"
318

419
const static char encodeLookup[] =

src/base64.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
// Public Domain: https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Original source Public Domain:
16+
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
17+
218
#pragma once
319

420
#include <cstdint>

wasm_vm_test.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
#include "include/proxy-wasm/wasm_vm.h"
216

317
#include "gtest/gtest.h"

0 commit comments

Comments
 (0)